paramiko / paramiko/paramiko

Python3 + tornado + pysftp causing exception and deadlock (bugs with asyncio module)

Open
#1,702 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

When running pysftp module through a tornado webserver the pysftp deadlocks on Python 3 with mysterious error messages that don't tell you what is going on. It was found after investigating the issue that it was possible to subclass Paramiko Transport class and use the following override on the run method to solve the issue

class myclass(paramiko.Transport):

        def run(self):
                loop = asyncio.new_event_loop()
                asyncio.set_event_loop(loop)                    
                paramiko.Transport.run(self)

To protect people from asyncio issues it is probably a good idea to create a new_event_loop by default. It might be possible to catch the exception and add an additional parameter to Paramiko to make it easy to fix asyncio issues with Paramiko and turn on/off event loop creation.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Paramiko's Transport.run method and reproduce the Python 3 failure in the reported tornado and pysftp setup. Compare the existing behavior with the proposed asyncio event-loop initialization and verify that the exception and deadlock are resolved without obscuring other failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.