Skip to content

Commit

Permalink
fix the issue : watch & unwatch the same folder on Windows may cause …
Browse files Browse the repository at this point in the history
…exception "Access Denied"

should close the dir handle
  • Loading branch information
Falldog committed Sep 5, 2014
1 parent 060906d commit 0fd68df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/watchdog/observers/winapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,12 @@ def get_directory_handle(path):
def close_directory_handle(handle):
try:
CancelIoEx(handle, None) # force ReadDirectoryChangesW to return
CloseHandle(handle) # close directory handle
except WindowsError:
return
try:
CloseHandle(handle) # close directory handle
except:
return


def read_directory_changes(handle, recursive):
Expand Down

0 comments on commit 0fd68df

Please sign in to comment.