|
Django used to have this, but at some point replaced it with a
dependency on facebook/watchman. Since we don't require this (and it's a
heavy dependency including runnning a separate daemon -- which is not
packaged on at least Debian stable versions), and didn't have it, the
django implementation would fall back on polling all files in a loop
once per second. And since there are thousands of files to depend on in
django environment, that could use a substantial amount of CPU.
We don't use this for the webserver itself, as that runs under smoething
like uwsgi, but we have two daemons at this point (scheduled task runner
and social media poster) that does.
So implement a local reloader based on inotify which is of course a lot
more efficient. We don't try any fancy detection magic, and instead just
watch every .py and.pyc file in a configurable set of directories (which
would typically consist of the code checkout and the virtualenv root,
but can be adapted).
If used, this adds a dependency on pyinotify, but the default
configuration is still to fall back on the django implementation.
|