
Hi Glyph, Thanks for the suggestion. I tried the suggestion.. While it fixes the self.channel NoneType issue.. It creates another issue. Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 827, in adapt adapt.actual.callback(extracted) File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 460, in callback self._startRunCallbacks(result) File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 568, in _startRunCallbacks self._runCallbacks() --- <exception caught here> --- File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks current.result = callback(current.result, *args, **kw) ...... request.finish() File "/usr/local/lib/python3.7/site-packages/twisted/web/server.py", line 268, in finish return http.Request.finish(self) File "/usr/local/lib/python3.7/site-packages/twisted/web/http.py", line 1071, in finish "Request.finish called on a request after its connection was lost; " builtins.RuntimeError: Request.finish called on a request after its connection was lost; use Request.notifyFinish to keep track of this. I have got some handle on the issue. I was wondering if you have any advise on how to debug the issue. Somewhere in the codebase are async/await code (from asyncio world). Hence, when the connection is closed down by client, seems like those pending coroutines are lingering on. def connectionLost(self, channel, reason): t = asyncio.all_tasks(asyncio.get_event_loop()) print("pending tasks ", len(t)) The above does shows the list of pending tasks. I am wondering if you have any advice on how to kill these coroutines? Also, I apologize if this is the wrong community to ask and if I should post it to asyncio community? Thanks for all the help. Regards, Waqar On Sat, Aug 3, 2019 at 3:56 PM Glyph <glyph@twistedmatrix.com> wrote:
On Aug 2, 2019, at 4:31 PM, Waqar Khan <wk80333@gmail.com> wrote:
Hi, I have a twisted server. And I have been seeing this annoying issue. Normally. when i develop and test it out. everything is fine.. But then I try to loadtest is via https://locust.io/
Again, everything is fine.. until I "stop" the test. Then, I see this 'Traceback (most recent call last):\n File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 88, in _run\n self._context.run(self._callback, *self._args)\n File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 827, in adapt\n adapt.actual.callback(extracted)\n File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 460, in callback\n self._startRunCallbacks(result)\n File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 568, in _startRunCallbacks\n self._runCallbacks()\n--- <exception caught here> ---\n File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks\n current.result = callback(current.result, *args, **kw)\n File .... File "/usr/local/lib/python3.7/site-packages/twisted/web/server.py", line 238, in write\n http.Request.write(self, data)\n File "/usr/local/lib/python3.7/site-packages/twisted/web/http.py", line 1118, in write\n self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\n'
I found this similar bug report: https://github.com/buildbot/buildbot/issues/4045 But I am using 19.2.1 twisted version..
There is a prerelease version, with this bug fixed, that is awaiting final release upload right now; can you try with Twisted==19.7.0rc1 ? That should fix this issue. If not, then we have some investigating to do :-).
-g
-g _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python