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

Support passing --poll to the auto plugin to better deal with symlink farms. #3757

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ New in master
Features
--------

* Support passing ``--poll`` to ``nikola auto`` to better deal with symlink farms.

Bugfixes
--------

Expand Down
14 changes: 13 additions & 1 deletion nikola/plugins/command/auto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@

try:
from watchdog.observers import Observer
from watchdog.observers.polling import PollingObserver
except ImportError:
Observer = None
PollingObserver = None

LRJS_PATH = os.path.join(os.path.dirname(__file__), 'livereload.js')
REBUILDING_REFRESH_DELAY = 0.35
Expand Down Expand Up @@ -159,6 +161,16 @@ class CommandAuto(Command):
'type': str,
'help': "Database backend ('dbm', 'json', 'sqlite3')",
'section': 'Arguments passed to `nikola build`'
},
{
# We might be able to improve on this
# if and when https://github.com/gorakhargosh/watchdog/issues/365
# is ever fixed.
'name': 'poll',
'long': 'poll',
'default': False,
'type': bool,
'help': 'Use polling to notice changes behind symbolic links. This may reduce performance.'
}
]

Expand Down Expand Up @@ -256,7 +268,7 @@ def _execute(self, options, args):
# Run an initial build so we are up-to-date. The server is running, but we are not watching yet.
loop.run_until_complete(self.run_initial_rebuild())

self.wd_observer = Observer()
self.wd_observer = Observer() if not options['poll'] else PollingObserver()
# Watch output folders and trigger reloads
if self.has_server:
self.wd_observer.schedule(NikolaEventHandler(self.reload_page, loop), out_folder, recursive=True)
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/test_dev_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def test_serves_root_dir(
"port": find_unused_port(),
"db-file": "/dev/null",
"backend": "No backend",
"no-server": False
"no-server": False,
"poll": False
}

# We start an event loop, run the test in an executor,
Expand Down
Loading