{"action":"created","issue":{"url":"https://api.github.com/repos/paramiko/paramiko/issues/520","repository_url":"https://api.github.com/repos/paramiko/paramiko","labels_url":"https://api.github.com/repos/paramiko/paramiko/issues/520/labels{/name}","comments_url":"https://api.github.com/repos/paramiko/paramiko/issues/520/comments","events_url":"https://api.github.com/repos/paramiko/paramiko/issues/520/events","html_url":"https://github.com/paramiko/paramiko/issues/520","id":72291752,"number":520,"title":"One 'bad' Transport thread hangs indefinitely at shutdown when multiple Transports are active","user":{"login":"colinmcintosh","id":4840146,"avatar_url":"https://avatars.githubusercontent.com/u/4840146?v=3","gravatar_id":"","url":"https://api.github.com/users/colinmcintosh","html_url":"https://github.com/colinmcintosh","followers_url":"https://api.github.com/users/colinmcintosh/followers","following_url":"https://api.github.com/users/colinmcintosh/following{/other_user}","gists_url":"https://api.github.com/users/colinmcintosh/gists{/gist_id}","starred_url":"https://api.github.com/users/colinmcintosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinmcintosh/subscriptions","organizations_url":"https://api.github.com/users/colinmcintosh/orgs","repos_url":"https://api.github.com/users/colinmcintosh/repos","events_url":"https://api.github.com/users/colinmcintosh/events{/privacy}","received_events_url":"https://api.github.com/users/colinmcintosh/received_events","type":"User","site_admin":false},"labels":[{"id":120561399,"url":"https://api.github.com/repos/paramiko/paramiko/labels/Bug","name":"Bug","color":"a04040","default":false},{"id":391162528,"url":"https://api.github.com/repos/paramiko/paramiko/labels/Hangs","name":"Hangs","color":"d93f0b","default":false},{"id":60522311,"url":"https://api.github.com/repos/paramiko/paramiko/labels/Needs%20investigation","name":"Needs investigation","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":50,"created_at":"2015-04-30T21:54:01Z","updated_at":"2016-12-28T21:47:10Z","closed_at":null,"body":"[MAINTAINER NOTE: a variant of this issue under Python 3 has been worked around as per [this comment](https://github.com/paramiko/paramiko/issues/520#issuecomment-225411888) but it's presumably still at large for Python 2 in some scenarios.]\n\nWhen running SSH connections to multiple devices the script will sometimes hang once the sys.exit(0) is reached. Once this is reached the script will hang indefinitely. It doesn't happen everytime but the more devices the script runs against the more likely it is to happen. It seems like it's related to the amount of time the script takes to run.\n\nThe last log message paramiko outputs is DEBUG:EOF in transport thread\n\nUsing the faulthandler module I dumped a stacktrace for when it hangs:\n\n```\nFatal Python error: Aborted\n\nThread 0x00007f47faff5700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f47fbff7700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f47fcff9700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f47fdffb700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f47feffd700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f480590f700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f48050ce700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nThread 0x00007f4807368700 (most recent call first):\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 204 in read_all\n  File \"build/bdist.linux-x86_64/egg/paramiko/packet.py\", line 341 in read_message\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1590 in run\n  File \"/usr/local/lib/python2.7/threading.py\", line 810 in __bootstrap_inner\n  File \"/usr/local/lib/python2.7/threading.py\", line 783 in __bootstrap\n\nCurrent thread 0x00007f480f7c4700 (most recent call first):\n  File \"/usr/local/lib/python2.7/threading.py\", line 358 in wait\n  File \"/usr/local/lib/python2.7/threading.py\", line 960 in join\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 1419 in stop_thread\n  File \"build/bdist.linux-x86_64/egg/paramiko/transport.py\", line 558 in close\n  File \"build/bdist.linux-x86_64/egg/paramiko/resource.py\", line 60 in callback\nAborted\n```\n\n It looks like all but LAST ONE of the resources closes correctly but the LAST ONE doesn't close correctly. The same thing happens if .close() is explicitly called on the Transport object. It will hang at that .close() method indefinitely, sometimes.\n\nThere is not one specific device it happens for either. I have tried many hosts and OS's with no specific one standing out a problem.\n"},"comment":{"url":"https://api.github.com/repos/paramiko/paramiko/issues/comments/269546247","html_url":"https://github.com/paramiko/paramiko/issues/520#issuecomment-269546247","issue_url":"https://api.github.com/repos/paramiko/paramiko/issues/520","id":269546247,"user":{"login":"tyler-8","id":17618971,"avatar_url":"https://avatars.githubusercontent.com/u/17618971?v=3","gravatar_id":"","url":"https://api.github.com/users/tyler-8","html_url":"https://github.com/tyler-8","followers_url":"https://api.github.com/users/tyler-8/followers","following_url":"https://api.github.com/users/tyler-8/following{/other_user}","gists_url":"https://api.github.com/users/tyler-8/gists{/gist_id}","starred_url":"https://api.github.com/users/tyler-8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyler-8/subscriptions","organizations_url":"https://api.github.com/users/tyler-8/orgs","repos_url":"https://api.github.com/users/tyler-8/repos","events_url":"https://api.github.com/users/tyler-8/events{/privacy}","received_events_url":"https://api.github.com/users/tyler-8/received_events","type":"User","site_admin":false},"created_at":"2016-12-28T21:47:10Z","updated_at":"2016-12-28T21:47:10Z","body":"Found this thread through Google, I'm running Python 2.7.13 and running into this issue with a multiprocessed script that uses paramiko 2.1.1. Here's my log output where it hangs:\r\n\r\n```\r\nINFO:paramiko.transport:Authentication (password) successful!\r\nDEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes\r\nDEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes\r\nDEBUG:paramiko.transport:Secsh channel 0 opened.\r\nDEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok\r\nDEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok\r\nDEBUG:paramiko.transport:EOF in transport thread\r\nDEBUG:paramiko.transport:EOF in transport thread\r\nDEBUG:paramiko.transport:EOF in transport thread\r\n```"}}
{"actor":{"display_login":"tyler-8"}}