-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close INotify filedescriptor if a directory is unwatched due to fs de…
…letion INotify will transparently unwatch a directory if it has been deleted from the filesystem. Not making a call to .loseConnection() results in leaving permanently opened [orphaned] file descriptors. We now close that file descriptor since it can no longer trigger.
- Loading branch information
1 parent
b60f198
commit 073da70
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INotify will close its file descriptor if a directory is automatically removed by twisted from the watchlist because it's deleted, avoiding orphaned filedescriptors. |
073da70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I have a question about this patch, Maybe I lack understand the inner workings of Inotify but shoulnd't you only call loseConnection when you don't have any watchpoints anymore?
for example i build a small test script:
when I run this script I'm interested in changes from both the "/tmp/test/1" and the "/tmp/test/2" directory. When somebody removes the "/tmp/test/1" directory I never get updates from the "/tmp/test/2" directory anymore because the connection is closed.
mkdir -p /tmp/test/1; mkdir -p /tmp/test/2
rm -r /tmp/test/1
rm -r /tmp/test/2
would produce:
python3 ./test.py
Change: FilePath(b'/tmp/test/1')
the removal of the second dir is never notified.
When I override the "loseConnection" and only close connections when i don't have any watchpoints anymore I do get a notify of the second directory removal:
python3 ./test.py
Change: FilePath(b'/tmp/test/1')
Change: FilePath(b'/tmp/test/2')
I hope I explained it clearly.
Kind regards,
Wesley
073da70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out. The change here does not look valid to me. I don't know if anyone else regularly monitors commit comments. The issue tracker, mailing list, or IRC channel are probably better forums for this kind of discussion. I left a comment with a link to this on the original issue, though, and I'll try to follow up in a couple days if no one else jumps on it.
073da70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it does introduce a bug! More discussion in the associated issue.
Thank you for catching it and tracking it down, I know it can be a pain.
073da70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, troubleshooting can also be fun, and it had to be fixed in my use case anyway.
thanks for the response!
Wesley