Module pyinotify :: Class ThreadedNotifier
[hide private]
[frames] | no frames]

Class ThreadedNotifier

source code


This notifier inherits from threading.Thread for instantiating a separate thread, and also inherits from Notifier, because it is a threaded notifier.

Note that everything possible with this class is also possible through Notifier. Moreover Notifier is _better_ under many aspects: not threaded, can be easily daemonized.

Instance Methods [hide private]
 
__init__(self, watch_manager, default_proc_fun=<ProcessEvent>, read_freq=0, treshold=0, timeout=None)
Initialization, initialize base classes.
source code
 
stop(self)
Stop the notifier's loop.
source code
 
loop(self)
Thread's main loop.
source code
 
run(self)
Start the thread's loop: read and process events until the method stop() is called.
source code

Inherited from threading.Thread: __repr__, getName, isAlive, isDaemon, is_alive, join, setDaemon, setName, start

Inherited from threading.Thread (private): _set_daemon

Inherited from threading._Verbose (private): _note

Inherited from Notifier: check_events, proc_fun, process_events, read_events

Inherited from Notifier (private): _sleep

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from threading.Thread: daemon, ident, name

Inherited from object: __class__

Method Details [hide private]

__init__(self, watch_manager, default_proc_fun=<ProcessEvent>, read_freq=0, treshold=0, timeout=None)
(Constructor)

source code 

Initialization, initialize base classes. read_freq, treshold and timeout parameters are used when looping.

Parameters:
  • watch_manager (WatchManager instance) - Watch Manager.
  • default_proc_fun (instance of ProcessEvent) - Default processing method.
  • read_freq (int) - if read_freq == 0, events are read asap, if read_freq is > 0, this thread sleeps max(0, read_freq - timeout) seconds.
  • treshold (int) - File descriptor will be read only if its size to read is >= treshold. If != 0, you likely want to use it in combination with read_freq because without that you keep looping without really reading anything and that until the amount to read is >= treshold. At least with read_freq you may sleep.
  • timeout (int) - see http://docs.python.org/lib/poll-objects.html#poll-objects Read the corresponding comment in the source code before changing it.
Overrides: object.__init__

stop(self)

source code 

Stop the notifier's loop. Stop notification. Join the thread.

Overrides: Notifier.stop

loop(self)

source code 

Thread's main loop. Don't meant to be called by user directly. Call start() instead.

Events are read only once time every min(read_freq, timeout) seconds at best and only if the size of events to read is >= treshold.

Parameters:
  • callback - Functor called after each event processing. Expects to receive notifier object (self) as first parameter.
  • daemonize - This thread is daemonized if set to True.
Overrides: Notifier.loop

run(self)

source code 

Start the thread's loop: read and process events until the method stop() is called. Never call this method directly, instead call the start() method inherited from threading.Thread, which then will call run().

Overrides: threading.Thread.run