Returning from socket.accept and threading issues.

Peter Hansen peter at
Wed Oct 20 02:11:43 CEST 2004

Christopher J. Bottaro wrote:
> I'm trying to write a fairly simple network program.  The main thread spawns
> a thread which creates a listener socket and then calls socket.accept on
> it.  socket.accept blocks indefinantly.  My problem is that when the main
> thread determines that it is time to quit, how do I get the spawned thread
> to exit?  Preferably I'd like the spawned thread to return from
> socket.accept when the main thread tells it to and then check a shared
> varible to determine if it should die or call socket.accept again.
> Any advice on this stuff would be greatly appreciated.

Would calling setDaemon() on the child threads not be sufficient?

(I'm unsure of the capitalization of that... check the docs or use
dir() to confirm what it's called.)


More information about the Python-list mailing list