Skip to content

Commit

Permalink
Use poll implementation to fix file descriptor leak
Browse files Browse the repository at this point in the history
Using select() here causes a file descriptor leak. We've replaced this
with a poll() implementation to avoid this.

The polling object needs to be opened with an eventmask that stops it
from blocking paramiko.

Fixes ploxiln#51

Co-authored-by: Dan Porter <[email protected]>
  • Loading branch information
mcontoliniproofpoint and Stealthii committed Apr 12, 2022
1 parent eb89992 commit ebd9d53
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fabric/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import socket
import time
from select import select
from select import poll
from collections import deque

import six
Expand Down Expand Up @@ -268,8 +268,9 @@ def input_loop(chan, f, using_pty):
if msvcrt.kbhit():
byte = msvcrt.getch()
elif waitable:
r, w, x = select([f], [], [], 0.0)
if f in r:
poller = poll()
poller.register(f, 1)
if poller.poll(f.fileno()):
byte = f.read(1)
else:
byte = f.read(1)
Expand Down

0 comments on commit ebd9d53

Please sign in to comment.