question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use 'watchgod' module instead of 'watchdog'

See original GitHub issue

I’m just starting to use Lektor but i noticed that it uses the watchdog module and one of the first comments that i saw at the quickstart tutorial was:

When I run lektor server I get OSError: inotify watch limit reached

I ran into that myself and thus i know what it is and that it’s related to watchdog but a lot of beginners probably don’t know. Instead of using separate approaches for each OS to watch for file-changes, i think that using the watchgod module could be a better and simpler solution.

Maybe it’s a good idea to at least check the module out and see if it fits better than the overly complex watchdog implementation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
dairikicommented, Feb 19, 2021

Hitting the inotify limits is a system problem, not a Lektor problem — sometimes even tail -f won’t run in this case — but it would be good if Lektor would degrade gracefully when this happens.

The watchdog distribution provides several different types of “Observers” that can be used to watch for file changes. On Linux, the default observer is InotifyObserver. There are other observers which are used on different OSes, but watchdog also provides a PollingObserver, which — while not as efficient as the other observers — should work anywhere.

From looking at the Lektor code, it appears that Lektor does not catch exceptions when creating the default (InotifyObserver on Linux) observer, so if that fails the server just craps out.

We should catch errors when creating the default observer, report them with a big warning, and then fall back to using PollingObserver.

1reaction
yagebucommented, Jan 16, 2021

Yes, that error sounds like it is related to file watching. Does it crash the server or does it just show this error message and work as expected?

I understand that the “one size fits all” approach of watchgod sounds appealing, but I don’t think that it would be a good choice for Lektor. Watching for file-changes is inherently platform-specific (by using inotify, fsevents, etc., which watchdog does) or inefficient (by using polling, which watchgod and which is also offered by watchdog). Also, after having looked rather dead for a while, the watchdog repo has gotten more active recently and there’s frequent releases, so I think that’s also not an argument against watchdog anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

watchgod - PyPI
Simple, modern file watching and code reload in python.
Read more >
installed watchdog module .but i am not access the module
Use PyCharm to write code in python It helps to solve module errors by itself It will show hint button when there is...
Read more >
Monitoring your File System using watchdog - Medium
Learn how to monitor any changes to a filesystem on a local or remote machine and take some action using watchdog. You will...
Read more >
External Watchgod Monitor S32K148 - NXP Community
I have some concerns regarding FS32K148 EWM Module: Is it ok to use the internal redundant watchdog EWM to generate the reset signal...
Read more >
encode/community - Gitter
Crazy indeed eg the module path and error message here don't even match: ... watchgod uses polling, but it seems like it's much...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found