[py-dev] Keyboard interrupt causes unclean shutdown in py.test & py.execnet

Simon 5kycsae02 at sneakemail.com
Thu Apr 23 07:05:59 CEST 2009


The core problem here appears to be that when the receive thread exits  
(because the ssh session has terminated), the main thread which is  
running the remote_exec is effectively orphaned. If the users remote  
exec task doesn't explicitly handle this, the main thread will stay  
open indefinitely.

The attached patch corrects this by running the receive thread as the  
main thread and the remote_exec as a child daemon thread.

Simon

On 21/04/2009, at 11:25 , Simon 5kycsae02-at-sneakemail.com |py-dev|  
wrote:

> This actually looks like an execnet issue, or maybe I'm not quite  
> understanding how this should work.
>
> If I run the following code, I get a bunch of stuff left over. Aside  
> from the ssh and shell instances, the main problem appears to be the  
> python exec instance on the remote machine (in this example  
> 'localhost'). If this process is killed, everything else seems to  
> sort itself out.
>
> Calling the exit() method of the gateway doesn't seem to help. Nor  
> does calling the close() method on the channel instance.
>
> =======================================
> cmd = """
> while True:
> 	pass
> """
>
> import py
> g=py.execnet.SshGateway("localhost")
> c=g.remote_exec(cmd)
> =======================================
>
> Simon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gateway.py.diff
Type: application/octet-stream
Size: 1561 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20090423/67313e58/attachment.obj>
-------------- next part --------------



More information about the Pytest-dev mailing list