PyQt and async I/O
donald.welch.nospam at hp.com
Tue Jul 1 23:01:43 CEST 2003
I was looking at the ASPN recipe for async I/O and Tkinter:
I am interested in using the recipe that is provided in the comments section
for PyQt courtesy of Laura Creighton.
I have a question though....
In the code, it says:
"One important thing to remember is that the thread has to yield
That appears in this code (the thread that will contain the async I/O):
This is where we handle the asynchronous I/O. For example, it may be
One important thing to remember is that the thread has to yield
# To simulate asynchronous I/O, we create a random number at
# random intervals. Replace the following 2 lines with the real
time.sleep(rand.random() * 0.3)
msg = rand.random()
If you were to use asyncore for this async I/O, there is no yielding that I
can see. Select() doesn't yield, and there is no time.sleep() in the
asyncore.loop() code. Even if I were to add a time.sleep() to the loop,
wouldn't the fact that select() blocks for some timeout value (default=30.0
sec) imply that it would only yield after the select() timed out each time
through the loop? That would seem to make for a pretty unresponsive UI.
Hopefully somebody can clue me into understanding this.
More information about the Python-list