Hi Juan,

On Thu, 2008-12-04 at 21:07 +0000, Juan Pablo Soto Barrera wrote:
> c) By the way, ... seemingly classes plugin.DaemonPlugin and kaa lack
> support for asynchronous IO; that is, support based on select(2) or
> poll(2) system calls. This (suppossedly) missing capability would
> allow to avoid many solutions based on awful race-conditions of
> threads (forbidden by my psychiatrist) or unnecessary overhead due to
> TCP/UDP inter-process communications to external daemons.

I can't speak to the other stuff, but kaa certainly supports async IO
via the IOMonitor and, more recently, IOChannel classes.

        def handle_read(data):
           print 'Got %d bytes' % len(datA)
        
        @kaa.timed(1)
        def status():
           print 'See, mainloop is still alive'
        
        # /dev/random blocks notoriously
        f = kaa.IOChannel(file('/dev/random'))
        f.signals['read'].connect(handle_read)
        status()
        kaa.main.run()
        

Or you could use a coroutine (more elegant):

        @kaa.coroutine()
        def get_real_random_data():
            f = kaa.IOChannel(file('/dev/random'))
            while f.alive:
                # This syntax requires python 2.5.  The coroutine
                # yields until data is ready.
                data = yield f.read()
                print 'Got %d bytes' % len(data)


If you don't want the high-level conveniences added by IOChannel, you
can use IOMonitor, which registers a file descriptor for monitoring and
will invoke a callback when the descriptor becomes readable or writable.
(This uses select internally.)

Cheers,
Jason.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to