Skip to content

Commit 6ab3fca

Browse files
committed
Fix "Bad file descriptor"
Somehow aliasing _read to conn._read breaks it, even though it's not a class method.
1 parent f14e088 commit 6ab3fca

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

plugin/core/transports.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,12 @@ class NodeIpcIO():
237237
_lines = 0
238238

239239
def __init__(self, conn: multiprocessing.connection._ConnectionBase):
240-
self._fd = conn.fileno()
241-
self._read = conn._read # type: ignore
242-
self._write = conn._write # type: ignore
240+
self._conn = conn
243241

244242
# https://github.com/python/cpython/blob/330f1d58282517bdf1f19577ab9317fa9810bf95/Lib/multiprocessing/connection.py#L378-L392
245243
def readline(self) -> bytearray:
246244
while self._lines == 0:
247-
chunk = self._read(self._fd, 65536) # type: bytes
245+
chunk = self._conn._read(self._conn.fileno(), 65536) # type: ignore
248246
self._buf += chunk
249247
self._lines += chunk.count(b'\n')
250248

@@ -255,7 +253,7 @@ def readline(self) -> bytearray:
255253
# https://github.com/python/cpython/blob/330f1d58282517bdf1f19577ab9317fa9810bf95/Lib/multiprocessing/connection.py#L369-L376
256254
def write(self, data: bytes) -> None:
257255
while len(data):
258-
n = self._write(self._fd, data) # type: int
256+
n = self._conn._write(self._conn.fileno(), data) # type: ignore
259257
data = data[n:]
260258

261259

plugin/core/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import contextlib
1515
import fnmatch
1616
import multiprocessing
17-
import multiprocessing.connection
1817
import os
1918
import posixpath
2019
import socket

0 commit comments

Comments
 (0)