Stephen Hansen wrote:
    Question: how can I do that? Use another threaded class? Is there
    some other way?

First of all, thanks for answer!

What OS? Does this have to be OS-independant?

Err, sorry -- this is Linux/UNIX only.

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?

I'm using multiple threads myself, one per IP basically, which in turn call paramiko calls, which itself is threaded.

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.

Thanks, that's still useful! Although...

1. if I don't install signal handler for SIGALRM I get this printed on the console at the end of execution:

Alarm clock

Although it does seem to close cleanly.

Is there any way to suppress this message?


2. If I do install signal handler for SIGALRM, I'm back at square one:

Exception in thread Thread-25 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File "/usr/lib/python2.4/threading.py", line 442, in __bootstrap
  File "./cssh.py", line 1003, in run
  File "./cssh.py", line 739, in ssh_connect_for_scp
File "build/bdist.linux-i686/egg/paramiko/transport.py", line 1006, in connect File "build/bdist.linux-i686/egg/paramiko/transport.py", line 1382, in _log
exceptions.TypeError: 'NoneType' object is not callable
Unhandled exception in thread started by

This happens even though I surround "connect" (line 1006) with catching all Exceptions:

try:
    self.trans.connect(hostkey=None, username=self.username, pkey = pkey)
except Exception, e:
    self.conerror = str(e)

        

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.

I will probably have to get the library author look at this.

Regards,
mk

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to