Open BotoX opened 7 years ago
Could this be solved by checking that self._transport._loop
is not None within StreamReader._maybe_resume_transport
?
When I add that it doesn't complain about _add_reader
not being an attribute of NoneType
.
That'd fix the exception but if something is left in the pipe then that is gone...
That's true, I'll look for a better fix with subprocess.
So I turned SubprocessStreamProtocol.process_exited
into a no-op but that will leave the Transport
unclosed but fixes the problem and all data is received. Perhaps there's a way to do this via Process
so the transport is only closed when an EOF is reached?
EDIT: So I've got a patch for this that I'll submit as a PR later tonight. Basically have to wait for all pipes to be closed/lost before finally closing the Transport
.
Submitted a PR #485 to fix this issue. Will work more on it tonight.
From https://bugs.python.org/issue23242#msg284930
The following script is used to reproduce the bug:
will produce following output and terminate with exception:
When the process exits https://github.com/python/asyncio/blob/master/asyncio/unix_events.py#L444 is called which sets this._loop = None Next time read() is called on the pipe the above exception is thrown. I have tried to fix this issue myself but would sometimes have read terminate too early and miss the last chunks of data.