Pyjo.Server.Reload.Backend.Poll - Auto-restarting development server backend using stat

from Pyjo.Server.Reload.Backend.Poll import Poll

backend = Poll()
if files := backend.modified_files():
    print('Files have been changed')

# Or import the module, as in Google Python Style Guide

import Pyjo.Server.Reload.Backend.Poll

backend = Pyjo.Server.Reload.Backend.Poll.new()
if files := backend.modified_files():
    print('Files have been changed')

Pyjo.Server.Reload.Backend.Poll is a backend for Pyjo.Server.Reload that checks the size and the modification time of the files with os.stat(), and waits for watch_timeout when none has changed.

See also

Pyjoyment, https://mojolicious.org.

Ported from Mojo::Server::Morbo::Backend::Poll of Mojolicious 9.49.

Classes

class Pyjo.Server.Reload.Backend.Poll.Pyjo_Server_Reload_Backend_Poll(**kwargs: Any)[source]

Pyjo.Server.Reload.Backend.Poll inherits all attributes and methods from Pyjo.Server.Reload.Backend and implements the following new ones.

modified_files() → list[str][source]
files = backend.modified_files()

Check file size and mtime to determine which files have changed, this is not particularly efficient, but very robust.