Keeping a function from taking to long--threads?

Rene Pijlman reply.in.the.newsgroup at my.address.is.invalid
Sun Mar 19 19:32:59 EST 2006


<brandon.mcginty at gmail.com>:
>Just wondering if anyone knows of a way to keep a function,
>E.g. socket.gethostbyaddr("12.34.56.78"),
>>From taking to long-if it's run for more than 1 second, the function
>gethostbyaddr will be terminated?

import socket
socket.setdefaulttimeout(1)

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl



More information about the Python-list mailing list