FSPoll – fs poll handle

class uv.FSPoll(path=None, interval=5000, loop=None, on_change=None)[source]

FS poll handles monitor a given filesystem path for changes. Unlike fs event handles, fs poll handles use stat() to detect when a file or directory has been changed so they can work on file systems where fs event handles can not.

Note

For maximum portability, use multi-second intervals. Sub-second intervals will not detect all changes on many file systems.

Raises:

uv.UVError – error while initializing the handle

Parameters:
  • path (unicode) – directory or filename to monitor
  • interval (int) – interval to be used for monitoring (in milliseconds)
  • loop (uv.Loop) – event loop the handle should run on
  • on_change (Callable[[uv.FSPoll, uv.StatusCode, uv.Stat, uv.Stat], None]) – callback which should be called on filesystem changes after the handle has been started
path

Directory or filename to monitor.

Warning

This property is writable, however you need to restart the handle if you change it during the handle is active.

Readonly:False
Type:unicode
interval

Interval to be used for monitoring (in milliseconds).

Warning

This property is writable, however you need to restart the handle if you change it during the handle is active.

Readonly:False
Type:int
on_change

Callback which should be called on filesystem changes after the handle has been started.

on_change(fs_poll, status, previous_stat, current_stat)
Parameters:
  • fs_event (uv.FSEvent) – handle the call originates from
  • status (uv.StatusCode) – may indicate any errors
  • previous_stat (uv.Stat) – previous filesystem path’s stat
  • current_stat (uv.Stat) – current filesystem path’s stat
Readonly:False
Type:Callable[[uv.FSPoll, uv.StatusCode, uv.Stat, uv.Stat], None]
start(path=None, interval=None, on_change=None)[source]

Start monitoring for filesystem changes. The change callback is invoked with status code < 0 if the given path does not exist or is inaccessible. The watcher is not stopped but your callback is not called again until something changes (e.g. when the file is created or the error reason changes).

Raises:
  • uv.UVError – error while starting the handle
  • uv.ClosedHandleError – handle has already been closed or is closing
Parameters:
  • path (unicode) – directory or filename to monitor (overrides the current path if specified)
  • interval (int) – interval to be used for monitoring (in milliseconds and overrides the current interval if specified)
  • on_change (Callable[[uv.FSPoll, uv.StatusCode, uv.Stat, uv.Stat], None]) – callback which should be called on filesystem changes
stop()[source]

Stop the handle. The callback will no longer be called.

Raises:uv.UVError – error while stopping the handle