root / docstrings / pyinotify.ThreadedNotifier-class.html

Revision a17385ae4cd3f952f689cfeee0d6e04841a4325e, 19.6 kB (checked in by Sebastien Martini <seb@…>, 7 hours ago)

Updated docstrings generated documentation.

  • Property mode set to 100644
Line 
1<?xml version="1.0" encoding="ascii"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3          "DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5<head>
6  <title>pyinotify.ThreadedNotifier</title>
7  <link rel="stylesheet" href="epydoc.css" type="text/css" />
8  <script type="text/javascript" src="epydoc.js"></script>
9</head>
10
11<body bgcolor="white" text="black" link="blue" vlink="#204080"
12      alink="#204080">
13<!-- ==================== NAVIGATION BAR ==================== -->
14<table class="navbar" border="0" width="100%" cellpadding="0"
15       bgcolor="#a0c0ff" cellspacing="0">
16  <tr valign="middle">
17  <!-- Home link -->
18      <th>&nbsp;&nbsp;&nbsp;<a
19        href="pyinotify-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21  <!-- Tree link -->
22      <th>&nbsp;&nbsp;&nbsp;<a
23        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25  <!-- Index link -->
26      <th>&nbsp;&nbsp;&nbsp;<a
27        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29  <!-- Help link -->
30      <th>&nbsp;&nbsp;&nbsp;<a
31        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32
33      <th class="navbar" width="100%"></th>
34  </tr>
35</table>
36<table width="100%" cellpadding="0" cellspacing="0">
37  <tr valign="top">
38    <td width="100%">
39      <span class="breadcrumbs">
40        <a href="pyinotify-module.html">Module&nbsp;pyinotify</a> ::
41        Class&nbsp;ThreadedNotifier
42      </span>
43    </td>
44    <td>
45      <table cellpadding="0" cellspacing="0">
46        <!-- hide/show private -->
47        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
48    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
49        <tr><td align="right"><span class="options"
50            >[<a href="frames.html" target="_top">frames</a
51            >]&nbsp;|&nbsp;<a href="pyinotify.ThreadedNotifier-class.html"
52            target="_top">no&nbsp;frames</a>]</span></td></tr>
53      </table>
54    </td>
55  </tr>
56</table>
57<!-- ==================== CLASS DESCRIPTION ==================== -->
58<h1 class="epydoc">Class ThreadedNotifier</h1><p class="nomargin-top"><span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier">source&nbsp;code</a></span></p>
59<center>
60<center>  <map id="uml_class_diagram_for_pyinotif_18" name="uml_class_diagram_for_pyinotif_18">
61<area shape="rect" href="pyinotify.ThreadedNotifier&#45;class.html#__init__" title="Initialization, initialize base classes." alt="" coords="17,302,641,321"/>
62<area shape="rect" href="pyinotify.ThreadedNotifier&#45;class.html#stop" title="Stop the notifier&#39;s loop." alt="" coords="17,321,641,340"/>
63<area shape="rect" href="pyinotify.ThreadedNotifier&#45;class.html#loop" title="Thread&#39;s main loop." alt="" coords="17,340,641,358"/>
64<area shape="rect" href="pyinotify.ThreadedNotifier&#45;class.html#run" title="Start the thread&#39;s loop: read and process events until the method stop() is called." alt="" coords="17,358,641,377"/>
65<area shape="rect" href="pyinotify.ThreadedNotifier&#45;class.html" title="This notifier inherits from threading.Thread for instantiating a separate thread, and also inherits from Notifier, because it is a threaded notifier." alt="" coords="16,277,643,378"/>
66<area shape="rect" href="javascript:void(0);" title="repr(x)" alt="" coords="148,97,313,116"/>
67<area shape="rect" href="javascript:void(0);" title="threading.Thread.start" alt="" coords="148,116,313,134"/>
68<area shape="rect" href="javascript:void(0);" title="threading.Thread.join" alt="" coords="148,134,313,153"/>
69<area shape="rect" href="javascript:void(0);" title="threading.Thread.getName" alt="" coords="148,153,313,172"/>
70<area shape="rect" href="javascript:void(0);" title="threading.Thread.setName" alt="" coords="148,172,313,190"/>
71<area shape="rect" href="javascript:void(0);" title="threading.Thread.isAlive" alt="" coords="148,190,313,209"/>
72<area shape="rect" href="javascript:void(0);" title="threading.Thread.isDaemon" alt="" coords="148,209,313,228"/>
73<area shape="rect" href="javascript:void(0);" title="threading.Thread.setDaemon" alt="" coords="148,228,313,246"/>
74<area shape="rect" href="javascript:void(0);" title="threading.Thread" alt="" coords="147,72,315,248"/>
75<area shape="rect" href="pyinotify.Notifier&#45;class.html#proc_fun" title="pyinotify.Notifier.proc_fun" alt="" coords="367,134,492,153"/>
76<area shape="rect" href="pyinotify.Notifier&#45;class.html#check_events" title="Check for new events available to read, blocks up to timeout milliseconds." alt="" coords="367,153,492,172"/>
77<area shape="rect" href="pyinotify.Notifier&#45;class.html#read_events" title="Read events from device, build _RawEvents, and enqueue them." alt="" coords="367,172,492,190"/>
78<area shape="rect" href="pyinotify.Notifier&#45;class.html#process_events" title="Routine for processing events from queue by calling their associated &#160;proccessing function (instance of ProcessEvent)." alt="" coords="367,190,492,209"/>
79<area shape="rect" href="pyinotify.Notifier&#45;class.html" title="Read notifications, process events." alt="" coords="365,109,493,210"/>
80<area shape="rect" href="javascript:void(0);" title="threading._Verbose" alt="" coords="173,10,288,42"/>
81</map>
82  <img src="uml_class_diagram_for_pyinotif_18.gif" alt='' usemap="#uml_class_diagram_for_pyinotif_18" ismap="ismap" class="graph-without-title" />
83</center>
84</center>
85<hr />
86<p>This notifier inherits from threading.Thread for instantiating a
87  separate thread, and also inherits from Notifier, because it is a
88  threaded notifier.</p>
89  <p>This class is only maintained for legacy reasons, everything possible
90  with this class is also possible with Notifier, but Notifier is _better_
91  under many aspects (not threaded, can be daemonized, won't unnecessarily
92  read for events).</p>
93
94<!-- ==================== INSTANCE METHODS ==================== -->
95<a name="section-InstanceMethods"></a>
96<table class="summary" border="1" cellpadding="3"
97       cellspacing="0" width="100%" bgcolor="white">
98<tr bgcolor="#70b0f0" class="table-header">
99  <td colspan="2" class="table-header">
100    <table border="0" cellpadding="0" cellspacing="0" width="100%">
101      <tr valign="top">
102        <td align="left"><span class="table-header">Instance Methods</span></td>
103        <td align="right" valign="top"
104         ><span class="options">[<a href="#section-InstanceMethods"
105         class="privatelink" onclick="toggle_private();"
106         >hide private</a>]</span></td>
107      </tr>
108    </table>
109  </td>
110</tr>
111<tr>
112    <td width="15%" align="right" valign="top" class="summary">
113      <span class="summary-type">&nbsp;</span>
114    </td><td class="summary">
115      <table width="100%" cellpadding="0" cellspacing="0" border="0">
116        <tr>
117          <td><span class="summary-sig"><a href="pyinotify.ThreadedNotifier-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
118        <span class="summary-sig-arg">watch_manager</span>,
119        <span class="summary-sig-arg">default_proc_fun</span>=<span class="summary-sig-default">&lt;ProcessEvent&gt;</span>,
120        <span class="summary-sig-arg">read_freq</span>=<span class="summary-sig-default">0</span>,
121        <span class="summary-sig-arg">treshold</span>=<span class="summary-sig-default">0</span>,
122        <span class="summary-sig-arg">timeout</span>=<span class="summary-sig-default">10000</span>)</span><br />
123      Initialization, initialize base classes.</td>
124          <td align="right" valign="top">
125            <span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.__init__">source&nbsp;code</a></span>
126           
127          </td>
128        </tr>
129      </table>
130     
131    </td>
132  </tr>
133<tr>
134    <td width="15%" align="right" valign="top" class="summary">
135      <span class="summary-type">&nbsp;</span>
136    </td><td class="summary">
137      <table width="100%" cellpadding="0" cellspacing="0" border="0">
138        <tr>
139          <td><span class="summary-sig"><a href="pyinotify.ThreadedNotifier-class.html#stop" class="summary-sig-name">stop</a>(<span class="summary-sig-arg">self</span>)</span><br />
140      Stop the notifier's loop.</td>
141          <td align="right" valign="top">
142            <span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.stop">source&nbsp;code</a></span>
143           
144          </td>
145        </tr>
146      </table>
147     
148    </td>
149  </tr>
150<tr>
151    <td width="15%" align="right" valign="top" class="summary">
152      <span class="summary-type">&nbsp;</span>
153    </td><td class="summary">
154      <table width="100%" cellpadding="0" cellspacing="0" border="0">
155        <tr>
156          <td><span class="summary-sig"><a href="pyinotify.ThreadedNotifier-class.html#loop" class="summary-sig-name">loop</a>(<span class="summary-sig-arg">self</span>)</span><br />
157      Thread's main loop.</td>
158          <td align="right" valign="top">
159            <span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.loop">source&nbsp;code</a></span>
160           
161          </td>
162        </tr>
163      </table>
164     
165    </td>
166  </tr>
167<tr>
168    <td width="15%" align="right" valign="top" class="summary">
169      <span class="summary-type">&nbsp;</span>
170    </td><td class="summary">
171      <table width="100%" cellpadding="0" cellspacing="0" border="0">
172        <tr>
173          <td><span class="summary-sig"><a href="pyinotify.ThreadedNotifier-class.html#run" class="summary-sig-name">run</a>(<span class="summary-sig-arg">self</span>)</span><br />
174      Start the thread's loop: read and process events until the method
175      stop() is called.</td>
176          <td align="right" valign="top">
177            <span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.run">source&nbsp;code</a></span>
178           
179          </td>
180        </tr>
181      </table>
182     
183    </td>
184  </tr>
185  <tr>
186    <td colspan="2" class="summary">
187    <p class="indent-wrapped-lines"><b>Inherited from <code>threading.Thread</code></b>:
188      <code>__repr__</code>,
189      <code>getName</code>,
190      <code>isAlive</code>,
191      <code>isDaemon</code>,
192      <code>join</code>,
193      <code>setDaemon</code>,
194      <code>setName</code>,
195      <code>start</code>
196      </p>
197    <div class="private">    <p class="indent-wrapped-lines"><b>Inherited from <code>threading.Thread</code></b> (private):
198      <code>_set_daemon</code>
199      </p></div>
200    <div class="private">    <p class="indent-wrapped-lines"><b>Inherited from <code>threading._Verbose</code></b> (private):
201      <code>_note</code>
202      </p></div>
203    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="pyinotify.Notifier-class.html">Notifier</a></code></b>:
204      <code><a href="pyinotify.Notifier-class.html#check_events">check_events</a></code>,
205      <code><a href="pyinotify.Notifier-class.html#proc_fun">proc_fun</a></code>,
206      <code><a href="pyinotify.Notifier-class.html#process_events">process_events</a></code>,
207      <code><a href="pyinotify.Notifier-class.html#read_events">read_events</a></code>
208      </p>
209    <div class="private">    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="pyinotify.Notifier-class.html">Notifier</a></code></b> (private):
210      <code><a href="pyinotify.Notifier-class.html#_sleep" onclick="show_private();">_sleep</a></code>
211      </p></div>
212    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
213      <code>__delattr__</code>,
214      <code>__getattribute__</code>,
215      <code>__hash__</code>,
216      <code>__new__</code>,
217      <code>__reduce__</code>,
218      <code>__reduce_ex__</code>,
219      <code>__setattr__</code>,
220      <code>__str__</code>
221      </p>
222    </td>
223  </tr>
224</table>
225<!-- ==================== PROPERTIES ==================== -->
226<a name="section-Properties"></a>
227<table class="summary" border="1" cellpadding="3"
228       cellspacing="0" width="100%" bgcolor="white">
229<tr bgcolor="#70b0f0" class="table-header">
230  <td colspan="2" class="table-header">
231    <table border="0" cellpadding="0" cellspacing="0" width="100%">
232      <tr valign="top">
233        <td align="left"><span class="table-header">Properties</span></td>
234        <td align="right" valign="top"
235         ><span class="options">[<a href="#section-Properties"
236         class="privatelink" onclick="toggle_private();"
237         >hide private</a>]</span></td>
238      </tr>
239    </table>
240  </td>
241</tr>
242  <tr>
243    <td colspan="2" class="summary">
244    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
245      <code>__class__</code>
246      </p>
247    </td>
248  </tr>
249</table>
250<!-- ==================== METHOD DETAILS ==================== -->
251<a name="section-MethodDetails"></a>
252<table class="details" border="1" cellpadding="3"
253       cellspacing="0" width="100%" bgcolor="white">
254<tr bgcolor="#70b0f0" class="table-header">
255  <td colspan="2" class="table-header">
256    <table border="0" cellpadding="0" cellspacing="0" width="100%">
257      <tr valign="top">
258        <td align="left"><span class="table-header">Method Details</span></td>
259        <td align="right" valign="top"
260         ><span class="options">[<a href="#section-MethodDetails"
261         class="privatelink" onclick="toggle_private();"
262         >hide private</a>]</span></td>
263      </tr>
264    </table>
265  </td>
266</tr>
267</table>
268<a name="__init__"></a>
269<div>
270<table class="details" border="1" cellpadding="3"
271       cellspacing="0" width="100%" bgcolor="white">
272<tr><td>
273  <table width="100%" cellpadding="0" cellspacing="0" border="0">
274  <tr valign="top"><td>
275  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
276        <span class="sig-arg">watch_manager</span>,
277        <span class="sig-arg">default_proc_fun</span>=<span class="sig-default">&lt;ProcessEvent&gt;</span>,
278        <span class="sig-arg">read_freq</span>=<span class="sig-default">0</span>,
279        <span class="sig-arg">treshold</span>=<span class="sig-default">0</span>,
280        <span class="sig-arg">timeout</span>=<span class="sig-default">10000</span>)</span>
281    <br /><em class="fname">(Constructor)</em>
282  </h3>
283  </td><td align="right" valign="top"
284    ><span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.__init__">source&nbsp;code</a></span>&nbsp;
285    </td>
286  </tr></table>
287 
288  <p>Initialization, initialize base classes. read_freq, treshold and
289  timeout parameters are used when looping.</p>
290  <dl class="fields">
291    <dt>Parameters:</dt>
292    <dd><ul class="nomargin-top">
293        <li><strong class="pname"><code>watch_manager</code></strong> (WatchManager instance) - Watch Manager.</li>
294        <li><strong class="pname"><code>default_proc_fun</code></strong> (instance of ProcessEvent) - Default processing method.</li>
295        <li><strong class="pname"><code>read_freq</code></strong> (int) - if read_freq == 0, events are read asap, if read_freq is &gt; 0,
296          this thread sleeps max(0, read_freq - timeout) seconds.</li>
297        <li><strong class="pname"><code>treshold</code></strong> (int) - File descriptor will be read only if its size to read is &gt;=
298          treshold. If != 0, you likely want to use it in combination with
299          read_freq because without that you keep looping without really
300          reading anything and that until the amount to read is &gt;=
301          treshold. At least with read_freq you may sleep.</li>
302        <li><strong class="pname"><code>timeout</code></strong> (int) - see http://docs.python.org/lib/poll-objects.html#poll-objects
303          Read the corresponding comment in the source code before changing
304          it.</li>
305    </ul></dd>
306    <dt>Overrides:
307        object.__init__
308    </dt>
309  </dl>
310</td></tr></table>
311</div>
312<a name="stop"></a>
313<div>
314<table class="details" border="1" cellpadding="3"
315       cellspacing="0" width="100%" bgcolor="white">
316<tr><td>
317  <table width="100%" cellpadding="0" cellspacing="0" border="0">
318  <tr valign="top"><td>
319  <h3 class="epydoc"><span class="sig"><span class="sig-name">stop</span>(<span class="sig-arg">self</span>)</span>
320  </h3>
321  </td><td align="right" valign="top"
322    ><span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.stop">source&nbsp;code</a></span>&nbsp;
323    </td>
324  </tr></table>
325 
326  <p>Stop the notifier's loop. Stop notification. Join the thread.</p>
327  <dl class="fields">
328    <dt>Overrides:
329        <a href="pyinotify.Notifier-class.html#stop">Notifier.stop</a>
330    </dt>
331  </dl>
332</td></tr></table>
333</div>
334<a name="loop"></a>
335<div>
336<table class="details" border="1" cellpadding="3"
337       cellspacing="0" width="100%" bgcolor="white">
338<tr><td>
339  <table width="100%" cellpadding="0" cellspacing="0" border="0">
340  <tr valign="top"><td>
341  <h3 class="epydoc"><span class="sig"><span class="sig-name">loop</span>(<span class="sig-arg">self</span>)</span>
342  </h3>
343  </td><td align="right" valign="top"
344    ><span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.loop">source&nbsp;code</a></span>&nbsp;
345    </td>
346  </tr></table>
347 
348  <p>Thread's main loop. don't meant to be called by user directly. Call
349  start() instead.</p>
350  <p>Events are read only once time every min(read_freq, timeout) seconds
351  at best and only if the size to read is &gt;= treshold.</p>
352  <dl class="fields">
353    <dt>Parameters:</dt>
354    <dd><ul class="nomargin-top">
355        <li><strong class="pname"><code>callback</code></strong> - Functor called after each event processing. Expects to receive
356          notifier object (self) as first parameter.</li>
357        <li><strong class="pname"><code>daemonize</code></strong> - This thread is daemonized if set to True.</li>
358    </ul></dd>
359    <dt>Overrides:
360        <a href="pyinotify.Notifier-class.html#loop">Notifier.loop</a>
361    </dt>
362  </dl>
363</td></tr></table>
364</div>
365<a name="run"></a>
366<div>
367<table class="details" border="1" cellpadding="3"
368       cellspacing="0" width="100%" bgcolor="white">
369<tr><td>
370  <table width="100%" cellpadding="0" cellspacing="0" border="0">
371  <tr valign="top"><td>
372  <h3 class="epydoc"><span class="sig"><span class="sig-name">run</span>(<span class="sig-arg">self</span>)</span>
373  </h3>
374  </td><td align="right" valign="top"
375    ><span class="codelink"><a href="pyinotify-pysrc.html#ThreadedNotifier.run">source&nbsp;code</a></span>&nbsp;
376    </td>
377  </tr></table>
378 
379  <p>Start the thread's loop: read and process events until the method
380  stop() is called. Never call this method directly, instead call the
381  start() method inherited from threading.Thread, which then will call
382  run().</p>
383  <dl class="fields">
384    <dt>Overrides:
385        threading.Thread.run
386    </dt>
387  </dl>
388</td></tr></table>
389</div>
390<br />
391<!-- ==================== NAVIGATION BAR ==================== -->
392<table class="navbar" border="0" width="100%" cellpadding="0"
393       bgcolor="#a0c0ff" cellspacing="0">
394  <tr valign="middle">
395