How best to achieve asynchronous socket input and output?
Andrew Bennetts
andrew-pythonlist at puzzling.org
Mon Nov 24 03:30:28 EST 2003
On Sun, Nov 23, 2003 at 06:21:12PM -0800, Kylotan wrote:
> I'm writing a wxPython telnet-like application that needs to be able
> to send and receive data independently of each other. The asyncore
> library comes close to what I want, but still requires I have a
> blocked thread (the one that calls asyncore.loop() ). It also seems a
> little unpredictable; one example of this is that when I based an
> example around the sample HTTP client (11.23.1 in the docs),
> handle_write never seemed to get called, and I had to call .send()
> directly, bypassing any buffering.
>
> Is there a better way of achieving what I want? Or something I need to
> know about the asyncore library to get it to do this?
You can use Twisted to do this, but unfortunately its builtin wxpython
support isn't very good. There is however a workaround for it:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/181780
(There's also a more comprehensive example app here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/203471)
If you don't want to switch to Twisted, perhaps a similar approach would
work for asyncore?
-Andrew.
More information about the Python-list
mailing list