Popular recipes tagged "application" but not "network"http://code.activestate.com/recipes/tags/application-network/2015-06-30T03:24:07-07:00ActiveState Code RecipesConsumer Application Skeleton (Python)
2015-06-30T03:24:07-07:00Vovanhttp://code.activestate.com/recipes/users/4192447/http://code.activestate.com/recipes/579074-consumer-application-skeleton/
<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 self._queue.next()
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.
self._log.info('Task done. Result: %s', future.result())
</code></pre>
Python single instance (cross-platform) (Python)
2013-02-10T16:22:33-08:00Esteban Castro Borsanihttp://code.activestate.com/recipes/users/4184010/http://code.activestate.com/recipes/578453-python-single-instance-cross-platform/
<p style="color: grey">
Python
recipe 578453
by <a href="/recipes/users/4184010/">Esteban Castro Borsani</a>
(<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/instance/">instance</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/single/">single</a>, <a href="/recipes/tags/singleton/">singleton</a>).
</p>
<p>Yet another way to get a single instance application.
This recipe uses file locking only.</p>
Python single instance (cross-platform) (Python)
2013-02-28T04:14:08-08:00Deepakhttp://code.activestate.com/recipes/users/4183429/http://code.activestate.com/recipes/578476-python-single-instance-cross-platform/
<p style="color: grey">
Python
recipe 578476
by <a href="/recipes/users/4183429/">Deepak</a>
(<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/instance/">instance</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/single/">single</a>, <a href="/recipes/tags/singleton/">singleton</a>).
</p>
<p>Yet another way to get a single instance application.
This recipe uses file locking only.</p>
Directory Size (GUI) (Python)
2011-02-09T13:47:54-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577567-directory-size-gui/
<p style="color: grey">
Python
recipe 577567
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/application/">application</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/sizeof/">sizeof</a>, <a href="/recipes/tags/tree/">tree</a>).
Revision 2.
</p>
<p>Have you ever wanted to find out how much room a particular directory was taking up on your hard drive? A roommate of mine in college was having trouble keeping track of where his hard drive space is going, so the following program provided a solution that allows a brief overview of a directory's size along with all of its children. A tree view is created using tkinter and is populated with the directory's name, cumulative size, immediate total file size, and full path. The search button is disabled during a search, and the directory listing with its children is automatically updated.</p>