Popular recipes tagged "threads"http://code.activestate.com/recipes/tags/threads/popular/2015-06-06T12:13:00-07:00ActiveState Code RecipesTail multiple pidgin IRC logfiles (Python)
2015-06-06T12:13:00-07:00Anton Vredegoorhttp://code.activestate.com/recipes/users/2667360/http://code.activestate.com/recipes/579066-tail-multiple-pidgin-irc-logfiles/
<p style="color: grey">
Python
recipe 579066
by <a href="/recipes/users/2667360/">Anton Vredegoor</a>
(<a href="/recipes/tags/colorize/">colorize</a>, <a href="/recipes/tags/irc/">irc</a>, <a href="/recipes/tags/iterators/">iterators</a>, <a href="/recipes/tags/logfiles/">logfiles</a>, <a href="/recipes/tags/merging/">merging</a>, <a href="/recipes/tags/nonblocking/">nonblocking</a>, <a href="/recipes/tags/pidgin/">pidgin</a>, <a href="/recipes/tags/tail/">tail</a>, <a href="/recipes/tags/threads/">threads</a>).
Revision 2.
</p>
<p>Tail multiple pidgin IRC logfiles. </p>
<p>Pidgin should be connected to IRC with the channels one
wants to tail joined, and it should save logs as text.</p>
<p>The script needs two arguments:</p>
<pre class="prettyprint"><code>the directory containing the directories with channel logs
a list of channel names, quoted and separated by spaces
</code></pre>
<p>Example command:</p>
<p>python pidgin-irctail.py
-d <a href="mailto:~/.purple/logs/irc/YOUR_IRC_HANDLE@irc.freenode.net">~/.purple/logs/irc/YOUR_IRC_HANDLE@irc.freenode.net</a>
-c "#chan1 #chan2 #chan3"</p>
<p>Some text elements are higlighted, and channel names are
inserted into the log lines after the time info.</p>
<p>If more than one channel is entered, the output of the logs
is merged. </p>
Creating a single instance application (Python)
2014-11-20T11:59:46-08:00Matteo Bertinihttp://code.activestate.com/recipes/users/4191156/http://code.activestate.com/recipes/578966-creating-a-single-instance-application/
<p style="color: grey">
Python
recipe 578966
by <a href="/recipes/users/4191156/">Matteo Bertini</a>
(<a href="/recipes/tags/threads/">threads</a>).
</p>
<p>Sometimes it is necessary to ensure that only one instance of application is running. This quite simple solution uses mutex to achieve this, and will run only on Windows platform.</p>
Simple python thread manager (Python)
2012-12-17T16:19:12-08:00Tom Wissinghttp://code.activestate.com/recipes/users/4184629/http://code.activestate.com/recipes/578385-simple-python-thread-manager/
<p style="color: grey">
Python
recipe 578385
by <a href="/recipes/users/4184629/">Tom Wissing</a>
(<a href="/recipes/tags/manager/">manager</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>A simple python static class handling basic threading. Designed for "worker" threads that loop forever over a function and the like.</p>
Simple python thread manager (Python)
2012-11-17T23:18:17-08:00Tino Deakhttp://code.activestate.com/recipes/users/4184300/http://code.activestate.com/recipes/578331-simple-python-thread-manager/
<p style="color: grey">
Python
recipe 578331
by <a href="/recipes/users/4184300/">Tino Deak</a>
(<a href="/recipes/tags/manager/">manager</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>A simple python static class handling basic threading. Designed for "worker" threads that loop forever over a function and the like.</p>
Reader-Writer lock with priority for writers (Python)
2011-09-28T21:45:04-07:00Mateusz Koboshttp://code.activestate.com/recipes/users/4178730/http://code.activestate.com/recipes/577803-reader-writer-lock-with-priority-for-writers/
<p style="color: grey">
Python
recipe 577803
by <a href="/recipes/users/4178730/">Mateusz Kobos</a>
(<a href="/recipes/tags/locking/">locking</a>, <a href="/recipes/tags/threads/">threads</a>).
Revision 2.
</p>
<p>The following class implements a reader-writer lock to use in the second readers-writers problem with python threads. In this problem, many readers can simultaneously access a share, and a writer has an exclusive access to this share. Additionally, the following constraints should be met: 1) no reader should be kept waiting if the share is currently opened for reading unless a writer is also waiting for the share, 2) no writer should be kept waiting for the share longer than absolutely necessary.</p>
Generic way to create a daemonized process in python (Python)
2012-03-26T14:56:17-07:00ajaymenon.khttp://code.activestate.com/recipes/users/4181225/http://code.activestate.com/recipes/578072-generic-way-to-create-a-daemonized-process-in-pyth/
<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>
Run async code inline, nonblocking (Python)
2011-11-23T10:13:31-08:00PRITAM Khttp://code.activestate.com/recipes/users/4180048/http://code.activestate.com/recipes/577959-run-async-code-inline-nonblocking/
<p style="color: grey">
Python
recipe 577959
by <a href="/recipes/users/4180048/">PRITAM K</a>
(<a href="/recipes/tags/asynchronous/">asynchronous</a>, <a href="/recipes/tags/closure/">closure</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>A decorator, that makes it easy to switch between the mainthread and background threads.</p>
ProgressBar class (Python)
2011-10-27T06:16:29-07:00Petr Zizkahttp://code.activestate.com/recipes/users/4179733/http://code.activestate.com/recipes/577926-progressbar-class/
<p style="color: grey">
Python
recipe 577926
by <a href="/recipes/users/4179733/">Petr Zizka</a>
(<a href="/recipes/tags/threads/">threads</a>).
</p>
<p>Progress bars are popular when trying to
show how much of a job has been completed.
In my case, it was encrypting and decrypting
files. A GUI interface was written, but
something was lacking. How was the user of
the program supposed to know if the program
was doing its job? A progress bar seemed like
a good answer, so a simple GUI progress bar
was written using Tkinter.</p>
Sleepsort (Python)
2011-06-17T05:17:22-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577756-sleepsort/
<p style="color: grey">
Python
recipe 577756
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/sorting/">sorting</a>, <a href="/recipes/tags/threads/">threads</a>).
Revision 2.
</p>
<p>Funky sort routine to demonstrate Python's threading basics.</p>
Multi-threaded Mandelbrot Fractal (Python)
2011-05-01T17:33:20-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577680-multi-threaded-mandelbrot-fractal/
<p style="color: grey">
Python
recipe 577680
by <a href="/recipes/users/4172570/">FB36</a>
(<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/thread/">thread</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>).
Revision 3.
</p>
<p>Multi-threaded Mandelbrot Fractal.</p>
POSIX Semaphore (FreeBSD) (Python)
2011-04-14T17:54:16-07:00David Naylorhttp://code.activestate.com/recipes/users/4177661/http://code.activestate.com/recipes/577655-posix-semaphore-freebsd/
<p style="color: grey">
Python
recipe 577655
by <a href="/recipes/users/4177661/">David Naylor</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/freebsd/">freebsd</a>, <a href="/recipes/tags/semaphores/">semaphores</a>, <a href="/recipes/tags/signal/">signal</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>POSIX Semaphore bindings for FreeBSD. </p>
A multithreaded, concurrent version of map() (Python)
2010-08-16T23:04:48-07:00Wai Yip Tunghttp://code.activestate.com/recipes/users/2382677/http://code.activestate.com/recipes/577360-a-multithreaded-concurrent-version-of-map/
<p style="color: grey">
Python
recipe 577360
by <a href="/recipes/users/2382677/">Wai Yip Tung</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/multithreading/">multithreading</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>map() applies a function to a list of data sequentially. This is a variation to map that execute each function call concurrently in a thread.</p>
Synchronization Decorator for Class Methods (Python)
2010-03-13T10:11:07-08:00Rodney Drenthhttp://code.activestate.com/recipes/users/4050661/http://code.activestate.com/recipes/577105-synchronization-decorator-for-class-methods/
<p style="color: grey">
Python
recipe 577105
by <a href="/recipes/users/4050661/">Rodney Drenth</a>
(<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/synchronize/">synchronize</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>Synchronizes access to methods of a class with either an instance or class specific
lock.</p>
Threadsafe observer pattern implemented as descriptor (Python)
2010-03-13T12:17:11-08:00Rodney Drenthhttp://code.activestate.com/recipes/users/4050661/http://code.activestate.com/recipes/577106-threadsafe-observer-pattern-implemented-as-descrip/
<p style="color: grey">
Python
recipe 577106
by <a href="/recipes/users/4050661/">Rodney Drenth</a>
(<a href="/recipes/tags/descriptor/">descriptor</a>, <a href="/recipes/tags/observer/">observer</a>, <a href="/recipes/tags/publish/">publish</a>, <a href="/recipes/tags/subscribe/">subscribe</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>This is a threadsafe version of <a href="http://code.activestate.com/recipes/576979/">recipe 576979</a>. A publish-subscribe (observer) pattern is implemented as a descriptor. Assigning a value notifies the observers.
Uses <a href="http://code.activestate.com/recipes/577105/">recipe 577105</a> as synchlock.py and <a href="http://code.activestate.com/recipes/576979/">recipe 576979</a> as Observer.py</p>
Run async code inline, nonblocking (Python)
2009-11-11T12:55:01-08:00Thomas Ahlehttp://code.activestate.com/recipes/users/4060075/http://code.activestate.com/recipes/576952-run-async-code-inline-nonblocking/
<p style="color: grey">
Python
recipe 576952
by <a href="/recipes/users/4060075/">Thomas Ahle</a>
(<a href="/recipes/tags/asynchronous/">asynchronous</a>, <a href="/recipes/tags/closure/">closure</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/threads/">threads</a>).
Revision 7.
</p>
<p>A decorator, that makes it easy to switch between the mainthread and background threads.</p>
Thread pool (grows on demand) (Python)
2009-11-03T02:28:12-08:00Pepe Aracilhttp://code.activestate.com/recipes/users/4171769/http://code.activestate.com/recipes/576910-thread-pool-grows-on-demand/
<p style="color: grey">
Python
recipe 576910
by <a href="/recipes/users/4171769/">Pepe Aracil</a>
(<a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>, <a href="/recipes/tags/thread_pool/">thread_pool</a>).
Revision 3.
</p>
<p>Thread pool that grows on demand.</p>
Timeout for (nearly) any callable (Python)
2010-12-20T06:51:35-08:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/576780-timeout-for-nearly-any-callable/
<p style="color: grey">
Python
recipe 576780
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/threads/">threads</a>, <a href="/recipes/tags/timeout/">timeout</a>).
Revision 5.
</p>
<p>This recipe provides 2 ways to invoke any callable with a time limit. Usable for Python 2.2 thru 3.0, see the Note in the module __doc__.</p>
Thread Pool (Python)
2008-11-30T05:42:59-08:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/576576-thread-pool/
<p style="color: grey">
Python
recipe 576576
by <a href="/recipes/users/4035877/">Louis RIVIERE</a>
(<a href="/recipes/tags/design_pattern/">design_pattern</a>, <a href="/recipes/tags/pool/">pool</a>, <a href="/recipes/tags/threads/">threads</a>, <a href="/recipes/tags/thread_pool/">thread_pool</a>).
Revision 4.
</p>
<p>Easy to use Thread Pool with a dynamically adjustable pool size.</p>
Thread pool mixin class for use with SocketServer.TCPServer (Python)
2008-07-10T18:52:58-07:00Michael Palmerhttp://code.activestate.com/recipes/users/1827292/http://code.activestate.com/recipes/574454-thread-pool-mixin-class-for-use-with-socketservert/
<p style="color: grey">
Python
recipe 574454
by <a href="/recipes/users/1827292/">Michael Palmer</a>
(<a href="/recipes/tags/threads/">threads</a>).
Revision 2.
</p>
<p>This is intended as a drop-in replacement for the ThreadingMixIn class in module SocketServer of the standard lib. Instead of spawning a new thread for each request, requests are processed by of pool of reusable threads.</p>
Heise mp3 downloader (Python)
2009-01-17T11:51:39-08:00d.schlabinghttp://code.activestate.com/recipes/users/4168903/http://code.activestate.com/recipes/576618-heise-mp3-downloader/
<p style="color: grey">
Python
recipe 576618
by <a href="/recipes/users/4168903/">d.schlabing</a>
(<a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>This little script presents new heise-news-articles individually by title and asks if it should download the corresponding mp3-file.</p>