#PermissionError [WinError 32]

1 messages · Page 1 of 1 (latest)

zealous sand
#

I am trying out using dagger with python on windows 10 but running into a puzzling error:

  File "C:\Users\winuser\.virtualenvs\dgrpy-7tEWe_Su\Lib\site-packages\dagger\engine\docker.py", line 120, in start_sync
    engine_session_bin_path = tmp_bin_path.rename(engine_session_bin_path)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\winuser\scoop\apps\python311\current\Lib\pathlib.py", line 1175, in rename
    os.rename(self, target)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\winuser\\.cache\\dagger\\temp-dagger-engine-session-6r7_6_n7' -> 'C:\\Users\\winuser\\.cache\\dagger\\dagger-engine-session-9ad18aca71b1b1ba.exe'

I found if I go and rename that file myself, dagger is working.
What's odd is that there's no problem creating the ~/.cache/dagger directory, or creating the initial file.
Permissions in windows appear fine.
I've tried with and without Pipenv creating the venv, and Python 3.10.9 and 3.11.1 - same issue.
I tried adding a retry to the file rename code, but it doesn't appear to do anything, it'll just fail the renaming in a loop.
So my workaround at the moment is to manually rename that file to the .exe and things are working.
This is using v0.2.1 of the SDK

zealous sand
#

Digging a little deeper, it seems like maybe docker still has an open handle to the file.
It does this quite consistently if I try and run the python code again

zealous sand
#

I can't really explain why, but de-denting these 3 lines fixes it.
The temp file is renamed to a .exe and dagger runs without issue

dusk jolt
#

@zealous sand can you try adding a tmp_bin.close() before the Path(tmp_bin.name)? my guess is that the subprocess could still be keeping the handle to the file for some reason after it finishes. And it would make sense for us to close the file before trying to rename it

thin heart
#

@zealous sand Can you please create an issue? \cc @winter narwhal

zealous sand
#

I'll create an issue