paramiko / paramiko/paramiko

Client connections not closed on client deletion

Open
#1,127 1 comment 1 reaction 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

client = paramiko.SSHClient('localhost')
client.exec_command('echo me')
del client

Connection still active. Resources not freed.

Creating more clients in same python process leads to memory leaks and eventually OOM.

Cause is client not calling transport.close() at any point.

Sub-classing SSHClient with a __del__ that includes transport.close() leads to race conditions and blocks most definitely related to cyclic references. This has been the case since 1.x and still persists in latest version.

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 the SSHClient lifecycle shown in the reproduction and trace how its transport is created and released. Investigate the reported transport.close() omission and cyclic-reference behavior, then verify that deleting clients frees connections and avoids leaks without introducing races or blocking.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.