Problem with blocking portably on sockets and Queue?

Tero Saarni terosaarni at hotmail.com
Tue Aug 5 15:08:03 EDT 2003


Hi,

I have several threads communicating with each other using events
stored in Queues. Threads block on Queue.get() until somebody
publishes an event in thread's event queue.

I need to add support for sockets to the system. Thread needs to 
unblock when:

  - there is socket ready to be read, or
  - there is event waiting in the queue

My first tought was to replace blocking on Queue.get() with blocking
on poll or select and dedicating file descriptors (created with os.pipe())
as an semaphore. Event publisher would write something to the write
end of the pipe when it puts an event to the queue, effectively 
unblocking the receiver.

BUT I noticed that select.poll() is not available on Windows and 
secondly Windows version of select.select() will accept only socket
descriptors.

What options do I have that are still portable also to Windows
platform?

---
Tero





More information about the Python-list mailing list