Close a socket externally

bryanjugglercryptographer at bryanjugglercryptographer at
Sat Oct 2 03:24:03 CEST 2004

The method I like is to compute a deadline for all the action on
the socket, then compute a new timeout for each blocking
operation.  The following isn't tested, or even compiled, but it
shows the idea:

deadline = time.time() + hard_limit_on_the_time
while stuff_to_do:
timeout = deadline - time.time()
if timeout < 0:
break  # time limit expired
(readable, _, _) =[mysock], [], [], timeout)
if ! readable:
break  # time limit expired
# at this point mysock has data available (barring weird


More information about the Python-list mailing list