[Python-Dev] blocking a non-blocking socket

Oleg Broytmann phd at phd.pp.ru
Sun Dec 2 21:31:44 CET 2007


On Sun, Dec 02, 2007 at 12:23:01PM -0800, Bill Janssen wrote:
[skip]
> Or, should I just set the timeout:
> 
>     timeout = self.gettimeout()
>     try:
>         self.settimeout(None)
> 	self.do_handshake()
>     finally:
>         self.settimeout(timeout)

   Yes, this is the correct solution for all cases: if the timeout is None
(socket is blocking) or 0 (non-blocking) or not-0 (blocking with timeout)
- just set it back.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-Dev mailing list