Exception generated during request completion
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 838
- Forks
- 123
- Avg merge
- 7h 58m
- Merged PRs (30d)
- 12
Description
I am seeing the error below in the twisted.log file for my Klein-based microservice. It looks as though there could be a race condition with the channel have being deleted prior to the cleanup call. Has anyone else seen this kind of behavior?
Thanks. Peter
2020-05-15 22:37:37+0000 [-] Unhandled Error writing response
Traceback (most recent call last):
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/internet/defer.py", line 1475, in gotResult
_inlineCallbacks(r, g, status)
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/internet/defer.py", line 1421, in _inlineCallbacks
status.deferred.callback(getattr(e, "value", None))
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/internet/defer.py", line 460, in callback
self._startRunCallbacks(result)
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/internet/defer.py", line 568, in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/klein/_resource.py", line 282, in write_response
request.finish()
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/web/server.py", line 248, in finish
return http.Request.finish(self)
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/web/http.py", line 1064, in finish
self._cleanup()
File "/home1/aim-user/anaconda3/envs/visual_page_classifier/lib/python3.6/site-packages/twisted/web/http.py", line 756, in _cleanup
self.channel.requestDone(self)
builtins.AttributeError: 'NoneType' object has no attribute 'requestDone'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with klein/_resource.py at write_response and trace the request lifecycle shown through Twisted's server.py and http.py. The report provides no reproduction steps or test location, so first establish when the channel becomes None; done would require a reproducible case and a verified fix or regression test for request completion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100