how do I listen on a socket without sucking up all the CPU time?
Donn Cave
donn at oz.net
Wed Oct 4 12:32:07 EDT 2000
Quoth blablu at gmx.net (Mike 'Cat' Perkonigg):
| I have some threads which are just looking if a queue is filled. So the
| main loop of these threads consist of:
|
| while runFlag:
| if inQueue.empty() == 0:
| doSomething...
|
| I could do:
|
| while runFlag:
| inData = inQueue.get(1)
| doSomething...
|
| but if I do that I can't check runFlag most of the time.
|
| My main understanding problem is now, what I have to do if I want to check
| this queue every 10 seconds without blocking other threads.
| Can I use time.sleep(10) as a timer or will that block the thread
| switching?
No, I'm sure time.sleep() will release the interpreter lock. Try it!
Donn Cave, donn at oz.net
More information about the Python-list
mailing list