-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Error when unpickling IncompleteReadError #76215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When using asyncio in combination with multiprocessing, a TypeError occur when readuntil() encounter an EOF instead of the delimiter. The error trace is:
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib64/python3.6/multiprocessing/pool.py", line 463, in _handle_results
task = get()
File "/usr/lib64/python3.6/multiprocessing/connection.py", line 252, in recv
return _ForkingPickler.loads(r)
TypeError: __init__() missing 1 required positional argument: 'expected' Fix proposed: |
This isn't so simple. >>> from asyncio.streams import IncompleteReadError
>>> import pickle
>>> e1 = IncompleteReadError(b'abc', 10)
>>> e2 = pickle.loads(pickle.dumps(e1))
>>> print(e1)
3 bytes read on a total of 10 expected bytes
>>> print(e2)
44 bytes read on a total of None expected bytes |
My first fix was indeed wrong. I went looking for similar Exception class in the code base and found the MaybeEncodingError in multiprocessing/pool.py By replacing the Error content with this one I don't have any error anymore. The message is kept identical. Does such a fix looks correct to you ? |
Typo in the last comment. The code should be: ''' |
No, this fix won't restore exception.args properly. I made a PR with a fix. |
There is the same issue with LimitOverrunError. I'm not sure that we should keep args the same. It affects __str__ and __repr__. badouxn overrides __str__. And the result of __repr__ currently looks like the exception constructor, but actually is not compatible with it. >>> IncompleteReadError(b'abc', 10)
IncompleteReadError('3 bytes read on a total of 10 expected bytes',) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: