Skip to content

Commit

Permalink
when taking ownership of stdin and stdout in PipeStream, the stdin an…
Browse files Browse the repository at this point in the history
…d stdout must be replaced by devnull as on one hand the code executed could write to it but also we will close the channels and thus cause exit code failures
  • Loading branch information
rlehfeld committed Jun 15, 2024
1 parent ac85a72 commit 1e7a7d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 8 additions & 2 deletions rpyc/core/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ def from_std(cls):
:returns: a :class:`PipeStream` instance
"""
return cls(sys.stdin, sys.stdout)
pipestream = cls(sys.stdin, sys.stdout)
sys.stdin = os.open(os.devnull, os.O_RDWR)
sys.stdout = sys.stdin
return pipestream

@classmethod
def create_pair(cls):
Expand Down Expand Up @@ -405,7 +408,10 @@ def __init__(self, incoming, outgoing):

@classmethod
def from_std(cls):
return cls(sys.stdin, sys.stdout)
pipestream = cls(sys.stdin, sys.stdout)
sys.stdin = os.open(os.devnull, os.O_RDWR)
sys.stdout = sys.stdin
return pipestream

@classmethod
def create_pair(cls):
Expand Down
1 change: 0 additions & 1 deletion rpyc/lib/colls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __getitem__(self, key):
obj = self._dict[key]()
if obj is None:
raise KeyError(key)
self[key] = obj
return obj

def __setitem__(self, key, value):
Expand Down

0 comments on commit 1e7a7d1

Please sign in to comment.