Imitating "tail -f"

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Nov 30 15:36:38 CET 2009


On 11:15 am, paul at boddie.org.uk wrote:
>On 22 Nov, 05:10, exar... at twistedmatrix.com wrote:
>>
>>"tail -f" is implemented by sleeping a little bit and then reading to
>>see if there's anything new.
>
>This was the apparent assertion behind the "99 Bottles" concurrency
>example:
>
>http://wiki.python.org/moin/Concurrency/99Bottles
>
>However, as I pointed out (and as others have pointed out here), a
>realistic emulation of "tail -f" would actually involve handling
>events from operating system mechanisms. Here's the exchange I had at
>the time:
>
>http://wiki.python.org/moin/Concurrency/99Bottles?action=diff&rev2=12&rev1=11
>
>It can be very tricky to think up good examples of multiprocessing
>(which is what the above page was presumably intended to investigate),
>as opposed to concurrency (which can quite easily encompass responding
>to events asynchronously in a single process).
>
>Paul
>
>P.S. What's Twisted's story on multiprocessing support? In my limited
>experience, the bulk of the work in providing usable multiprocessing
>solutions is in the communications handling, which is something
>Twisted should do very well.

Twisted includes a primitive API for launching and controlling child 
processes, reactor.spawnProcess.  It also has several higher-level APIs 
built on top of this aimed at making certain common tasks more 
convenient.  There is also a third-party project called Ampoule which 
provides a process pool to which it is is relatively straightforward to 
send jobs and then collect their results.

Jean-Paul



More information about the Python-list mailing list