socket.accept()
Peter Hansen
peter at engcorp.com
Tue Feb 11 11:37:37 EST 2003
marco wrote:
>
> very much simplified a function looks like this:
>
> def run():
> mysocket = socket.socket(blabla)
> mysocket.bind(blabla)
> mysocket.listen(1)
> while 1:
> newsocket, addr = mysocket.accept()
> # and so on...
>
> now this loop is in a thread which, once started, will
> never die. since a thread must (?) be killed at the
> end of the program i do have a problem, because the
> program just doesn't exit
> how can i stopp the .accept()?
You cannot stop the accept, but you can contrive to have it
block the program for no longer than a brief moment, at which
point the thread can check a flag (as others have suggested)
to see if the thread should exit.
What you're looking for is the "select" standard module.
-Peter
More information about the Python-list
mailing list