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

Class Notifier

source code


Read notifications, process events.

Instance Methods [hide private]
 
__init__(self, watch_manager, default_proc_fun=<ProcessEvent>, read_freq=0, treshold=0, timeout=None)
Initialization.
source code
 
proc_fun(self) source code
bool
check_events(self)
Check for new events available to read, blocks up to timeout milliseconds.
source code
 
read_events(self)
Read events from device, build _RawEvents, and enqueue them.
source code
 
process_events(self)
Routine for processing events from queue by calling their associated proccessing function (instance of ProcessEvent).
source code
 
__daemonize(self, pid_file=None, force_kill=False, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null')
pid_file: file to which pid will be written.
source code
 
_sleep(self, ref_time) source code
 
loop(self, callback=None, daemonize=False, **args)
Events are read only once time every min(read_freq, timeout) seconds at best and only if the size to read is >= treshold.
source code
 
stop(self)
Close the inotify's instance (close its file descriptor).
source code

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

Properties [hide private]

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. 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. But if timeout is None it can be different because poll is blocking waiting for something to read.
  • 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) - http://docs.python.org/lib/poll-objects.html#poll-objects
Overrides: object.__init__

check_events(self)

source code 

Check for new events available to read, blocks up to timeout milliseconds.

Returns: bool
New events to read.

process_events(self)

source code 

Routine for processing events from queue by calling their associated proccessing function (instance of ProcessEvent). It also do internal processings, to keep the system updated.

__daemonize(self, pid_file=None, force_kill=False, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null')

source code 

pid_file: file to which pid will be written. force_kill: if True kill the process associated to pid_file. stdin, stdout, stderr: files associated to common streams.

loop(self, callback=None, daemonize=False, **args)

source code 

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

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

stop(self)

source code 

Close the inotify's instance (close its file descriptor). It destroys all existing watches, pending events,...