Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable possibility to enforce PollingObserver by setting the environment variable WATCHMEDO_FORCE_POLLING #289

Closed
wants to merge 7 commits into from
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ response to events:
--command='echo "${watch_src_path}"' \
.

You can enforce usage of the PollingObserver by setting the environment
variable WATCHDOG_FORCE_POLLING to an non empty value. This is for example usable
if you are in an environment where the default observer will not work. For example
when you are monitoring files on a shared folder inside a virtual machine where
the host file change events doesn't propagate to the guest.

Please see the help information for these commands by typing:

.. code-block:: bash
Expand Down
3 changes: 2 additions & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,5 @@ Windows Vista and later
OS Independent Polling
|project_name| also includes a fallback-implementation that polls
watched directories for changes by periodically comparing snapshots
of the directory tree.
of the directory tree. You can enforce this behavior by setting the
environment variable WATCHDOG_FORCE_POLLING to a non empty value.
6 changes: 5 additions & 1 deletion src/watchdog/observers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@
"""

import warnings
import os
from watchdog.utils import platform
from watchdog.utils import UnsupportedLibc

if platform.is_linux():
if os.environ.get('WATCHDOG_FORCE_POLLING', False):
from .polling import PollingObserver as Observer

elif platform.is_linux():
try:
from .inotify import InotifyObserver as Observer
except UnsupportedLibc:
Expand Down