timer for a function
apt.shansen at gmail.com
Tue Feb 9 03:44:17 CET 2010
On Fri, Feb 5, 2010 at 9:23 AM, mk <mrkafk at gmail.com> wrote:
> On paramiko mailing list I got the suggestion to build a timer and then
> quit this by myself:
> The timeout option in connect() is for the socket, not for the entire
>> operation. You are connected, so that timeout is no longer relevant.
>> You would probably have to wrap the transport.connect() method in a
>> timer to break out of this early.
> Question: how can I do that? Use another threaded class? Is there some
> other way?
What OS? Does this have to be OS-independant? Are you using more then one
transport/SSLClient in your process and you want to just kill one (and any
of its child threads), or are you doing one per process?
If you want to terminate -all- threads your process is running in a given
timeframe, using a SIGALRM in the signal module will do it, I believe--
provided you don't need to support windows. I had a contextlib manager do
that for awhile. If you only want to terminate one (and its
child-threads)... you're out of luck, I think. The only way to terminate a
thread in Python is with conditions/events/whatever and the thread
cooperating and exiting on its own.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list