gorakhargosh / watchdog

Python library and shell utilities to monitor filesystem events.
http://packages.python.org/watchdog/
Apache License 2.0
6.64k stars 698 forks source link

Use `select.poll()` if available. #1078

Closed g-pichler closed 1 month ago

g-pichler commented 1 month ago

Details:

As stated in the select() man page:

WARNING: select() can monitor only file descriptors numbers that are less than FD_SETSIZE
         (1024)—an unreasonably low limit for many modern applications—and this limitation will not
         change.

This can lead to ValueError: filedescriptor out of range in select() when using watchdog. Following the advice of the select() man page, we use select.poll() instead, if available. The call to select() used as a fallback.


Fixes #1079.

BoboTiG commented 1 month ago

Nice, thank you @g-pichler !

Would you mond adding a line in the changelog too, please?

BoboTiG commented 1 month ago

That's OK on my side. LMK when you are ready for the merge.

BoboTiG commented 1 month ago

Out of curiosity, any pros/cons to prefer epoll()?

g-pichler commented 1 month ago

I have to be honest, I did not look into epoll() after my issue was resolved using poll(). I'm also not familiar with polling and did not want to invest more time, considering I had a workable solution and the man page was pointing at poll() as a suitable replacement.

From my side, you can merge at your convenience. I think a MacOS unit-test keeps failing from time to time, but I believe this might be a timing issue in the CI/CD.