Top-rated recipes tagged "daemon" Code RecipesGeneric way to create a daemonized process in python (Python) 2012-03-26T14:56:17-07:00ajaymenon.k <p style="color: grey"> Python recipe 578072 by <a href="/recipes/users/4181225/">ajaymenon.k</a> (<a href="/recipes/tags/daemon/">daemon</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/threads/">threads</a>). Revision 4. </p> <p>A simple daemon that will constantly keep track the size of your inbox and when it exceeds a certain size, will send you a reminder email.</p> Consumer Application Skeleton (Python) 2015-06-30T03:24:07-07:00Vovan <p style="color: grey"> Python recipe 579074 by <a href="/recipes/users/4192447/">Vovan</a> (<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/consumer/">consumer</a>, <a href="/recipes/tags/daemon/">daemon</a>, <a href="/recipes/tags/framework/">framework</a>). Revision 2. </p> <h4 id="consumer-application-skeleton">Consumer Application Skeleton</h4> <p>This is very basic skeleton for data processing application implementing consumer pattern:</p> <pre class="prettyprint"><code>while is_running(): task = get_next_task_from_queue() if task: submit_task_for_processing(task) else: sleep_for_a_moment() </code></pre> <p>Here's an example:</p> <pre class="prettyprint"><code>class ExampleApp(ConsumerAppBase): def _get_next_task(self): # Get next task from the queue. return def _run_task(self, task): # This code's being executed in separate worker thread of # ThreadPoolExecutor return task / 2 def _on_task_done(self, task, future): # Once worker thread finished - task results are available # in _on_task_done() callback as a concurrent.futures.Future object.'Task done. Result: %s', future.result()) </code></pre> Context manager for a daemon pid file (Python) 2013-10-07T21:03:30-07:00Graham Poulter <p style="color: grey"> Python recipe 577911 by <a href="/recipes/users/4172291/">Graham Poulter</a> (<a href="/recipes/tags/daemon/">daemon</a>, <a href="/recipes/tags/pid/">pid</a>). Revision 3. </p> <p>Context manager for a pid (process id) file used to tell whether a daemon process is still running.</p> <p>On entry, it writes the pid of the current process to the path. On exit, it removes the file.</p> <p>Designed to work with python-daemon.</p> logging support for python daemon (Python) 2010-10-25T15:22:18-07:00Bud P. Bruegger <p style="color: grey"> Python recipe 577442 by <a href="/recipes/users/4175472/">Bud P. Bruegger</a> (<a href="/recipes/tags/daemon/">daemon</a>, <a href="/recipes/tags/logging/">logging</a>). </p> <p>The recipe shows how to subclass python-daemon's [1] DaemonContext to add logging support. In particular, it is possible to ask to keep the files related to a list of loggers (loggers_preserve) open and to redirect stdout and stderr to a logger (e.g., one using a RotatingFileHandler). </p> <p>[1] See <a href="" rel="nofollow"></a></p>