Close a socket externally

bryanjugglercryptographer at yahoo.com bryanjugglercryptographer at yahoo.com
Fri Oct 1 21:24:03 EDT 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, _, _) = select.select([mysock], [], [], timeout)
if ! readable:
break  # time limit expired
# at this point mysock has data available (barring weird
things)


-- 
--Bryan




More information about the Python-list mailing list