You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a script which will wrap a closed source data editing program. I need my script to monitor the files generated by the editor so that I can post-process them. Since I am post-processing I have the editor operate in a tempfile.mkdtemp() directory and then try to delete the directory at the end. The monitoring works ok but I get an exception when I try to delete the temporary directory. There is no issue when I monitor the temp directory instead of the created sub-directory (I can use it this way with multiple temp directories as a work-around). Here's my attempt at a minimal recreation of the issue.
fromwatchdog.observersimportObserverfromwatchdog.eventsimportFileSystemEventHandlerimporttempfileimportshutilimportosclassHandler(FileSystemEventHandler):
defon_modified(self, event):
print('Modified: {}'.format(event.src_path))
if__name__=="__main__":
temp_directory=tempfile.mkdtemp()
print(temp_directory)
sub_dir=os.path.join(temp_directory, 'subdir')
os.makedirs(sub_dir)
event_handler=Handler()
observer=Observer()
observer.schedule(event_handler, sub_dir, recursive=True)
observer.start()
observer.stop()
observer.join()
try:
shutil.rmtree(temp_directory)
print("No exception using shutil.rmtree(). Must not ""be exhibiting the reported issue.")
exceptExceptionase:
print("Exception occurred using shutil.rmtree().")
print(e)
print('\n'.join(os.listdir(temp_directory)))
While stepping through I was monitoring the active file handles for the process in Process Explorer and the directory name shows up when the call is made to the Windows function CancelIoEx() inside close_directory_handle() in winapi.py.
I have run this in both Python 3.3 and 3.4 with the same results. The OS is Windows7 x64 (with lots of annoying security software since it is my work laptop). I tried it on my coworkers computer with a similar setup and it, not surprisingly, had the same issue. PIP freeze provides:
I am working on a script which will wrap a closed source data editing program. I need my script to monitor the files generated by the editor so that I can post-process them. Since I am post-processing I have the editor operate in a tempfile.mkdtemp() directory and then try to delete the directory at the end. The monitoring works ok but I get an exception when I try to delete the temporary directory. There is no issue when I monitor the temp directory instead of the created sub-directory (I can use it this way with multiple temp directories as a work-around). Here's my attempt at a minimal recreation of the issue.
While stepping through I was monitoring the active file handles for the process in Process Explorer and the directory name shows up when the call is made to the Windows function CancelIoEx() inside close_directory_handle() in winapi.py.
I have run this in both Python 3.3 and 3.4 with the same results. The OS is Windows7 x64 (with lots of annoying security software since it is my work laptop). I tried it on my coworkers computer with a similar setup and it, not surprisingly, had the same issue. PIP freeze provides:
The text was updated successfully, but these errors were encountered: