How best to achieve asynchronous socket input and output?
Albert Hofkamp
hat at se-126.se.wtb.tue.nl
Mon Nov 24 03:12:07 EST 2003
On 23 Nov 2003 18:21:12 -0800, Kylotan <kylotan at hotmail.com> 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?
I usually jump immediately to select, which maps almost directly to select(2),
giving a lot of control, and lack of portability for non-unix systems.
In the context of GUI's, maybe you can get the eventloop of wxpython to
wait for file I/O on the sockets, some GUI libraries provide such a hook
(GUI handling in the end means waiting for data from the X11 server, ie
a select-like thing).
Otherwise you must poll, or use a seperate thread.
--
Albert
--
Unlike popular belief, the .doc format is not an open publically available format.
More information about the Python-list
mailing list