文件相关事件
Monitor a file descriptor for changes in the read or write availability, and with a timeout given by timeout_s
seconds.
The keyword arguments determine which of read and/or write status should be monitored; at least one of them must be set to true
.
The returned value is an object with boolean fields readable
, writable
, and timedout
, giving the result of the polling.
— Function
Monitor a file for changes by polling every interval_s
seconds until a change occurs or timeout_s
seconds have elapsed. The interval_s
should be a long period; the default is 5.007 seconds.
The current
status object may be a StatStruct
, an EOFError
(indicating the timeout elapsed), or some other Exception
subtype (if the stat
operation failed - for example, if the path does not exist).
To determine when a file was modified, compare current isa StatStruct && mtime(prev) != mtime(current)
to detect notification of changes. However, using watch_file for this operation is preferred, since it is more reliable and efficient, although in some situations it may not be available.
— Function
Watch file or directory path
for changes until a change occurs or timeout_s
seconds have elapsed.
The returned value is an object with boolean fields changed
, renamed
, and , giving the result of watching the file.
FileWatching.watch_folder — Function
Watches a file or directory path
for changes until a change has occurred or timeout_s
seconds have elapsed.
This will continuing tracking changes for path
in the background until unwatch_folder
is called on the same path
.
The returned value is an pair where the first field is the name of the changed file (if available) and the second field is an object with boolean fields changed
, renamed
, and timedout
, giving the event.
This behavior of this function varies slightly across platforms. See for more detailed information.
Stop background tracking of changes for path
. It is not recommended to do this while another task is waiting for watch_folder
to return on the same path, as the result may be unpredictable.