Improve support for fsencode, fsdecode, and path object detection, and allow rm_watch to take a path#40
Open
zbentley wants to merge 2 commits into
Conversation
…d allow rm_watch to take a path
Owner
|
Hi @zbentley, I think it's out of scope for this project to track watches itself and accept filepaths or Paths for rm_watch - I want the interface to be very close to the underlying inotify interface. In the latest release 2.0.0, I've dropped support for Python < 3.6 via the compatibility switches |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four changes in this PR:
rm_watchto take a PathLike or a descriptor number.add_watchnow tracks created watches internally, andrm_watchuses and updates that tracker.close()clears the tracker out, which will help with the rare (but pertinent for me) case in which many hundreds of paths have been watched, taking up memory (and not being garbage collected right away since I use the raw inotify fd in asyncio, keeping the object around in a global deliberately-leaked pool even after it's closed; the other PR I submitted will help provide ways around that).fsencodeandfsdecodefunctionality inbackports.os, which handles really nasty filesystem names better than the current implementations.backports.osis pure python, has no transitives, and only implements those two functions, so it's not pulling in a bunch of extra stuff.parts, this code probes foros.PathLikeandpathlib.Pathdirectly. This helps deal with custom/weird path objects that may exist in the future. Hey, I said it was pedantic :)longsupport on Python 2.Open questions:
pathlib2.Pathas well? It's the most popular pathlib backport (measured by stars/grep). Not proposing adding pathlib2 toinstall_requires, but I could try-import it and add it to theisinstancecheck.