Re: self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\
Waqar Khan <[email protected]> Sun, 4 Aug 2019 20:57:10 -0400
| Newsgroups | gmane.comp.python.twisted |
|---|---|
| Message-ID | <CAJuJkHPj6XqGaLvutuGQe9bzHTKBx37PgWxcOSFA++vP7nLgqA@mail.gmail.com> |
--===============0301031311417894032==
Content-Type: multipart/alternative; boundary="000000000000beb9c2058f5430ab"
--000000000000beb9c2058f5430ab
Content-Type: text/plain; charset="UTF-8"
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 <[email protected]> wrote:
>
>
> On Aug 2, 2019, at 4:31 PM, Waqar Khan <[email protected]> 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
> [email protected]
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
--000000000000beb9c2058f5430ab
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi Glyph,<div>=C2=A0 Thanks for the suggestion.</div><div>=
I tried the suggestion.. While it fixes the self.channel NoneType issue.. I=
t creates another issue.</div><div><br></div><div>Traceback (most recent ca=
ll last):<br>=C2=A0 File "/usr/local/Cellar/python/3.7.1/Frameworks/Py=
thon.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 88,=
in _run<br>=C2=A0 =C2=A0 self._context.run(self._callback, *self._args)<br=
>=C2=A0 File "/usr/local/lib/python3.7/site-packages/twisted/internet/=
defer.py", line 827, in adapt<br>=C2=A0 =C2=A0 adapt.actual.callback(e=
xtracted)<br>=C2=A0 File "/usr/local/lib/python3.7/site-packages/twist=
ed/internet/defer.py", line 460, in callback<br>=C2=A0 =C2=A0 self._st=
artRunCallbacks(result)<br>=C2=A0 File "/usr/local/lib/python3.7/site-=
packages/twisted/internet/defer.py", line 568, in _startRunCallbacks<b=
r>=C2=A0 =C2=A0 self._runCallbacks()<br>--- <exception caught here> -=
--<br>=C2=A0 File "/usr/local/lib/python3.7/site-packages/twisted/inte=
rnet/defer.py", line 654, in _runCallbacks<br>=C2=A0 =C2=A0 current.re=
sult =3D callback(current.result, *args, **kw)<br>......<br>=C2=A0 =C2=A0 r=
equest.finish()<br>=C2=A0 File "/usr/local/lib/python3.7/site-packages=
/twisted/web/server.py", line 268, in finish<br>=C2=A0 =C2=A0 return h=
ttp.Request.finish(self)<br>=C2=A0 File "/usr/local/lib/python3.7/site=
-packages/twisted/web/http.py", line 1071, in finish<br>=C2=A0 =C2=A0 =
"Request.finish called on a request after its connection was lost; &qu=
ot;<br>builtins.RuntimeError: Request.finish called on a request after its =
connection was lost; use Request.notifyFinish to keep track of this.<br></d=
iv><div><br></div><div><br></div><div>=C2=A0I have got some handle on the i=
ssue. I was wondering if you have any advise on how to debug the issue.=C2=
=A0</div><div>Somewhere in the codebase are async/await code (from asyncio =
world). Hence, when the connection is closed down by client, seems like tho=
se pending coroutines are lingering on.</div><div><br></div><div><pre style=
=3D"background-color:rgb(248,248,255);color:rgb(0,0,0);font-family:Menlo;fo=
nt-size:9pt"><span style=3D"font-weight:bold">def </span><span style=3D"bac=
kground-color:rgb(255,229,144)">connectionLost</span>(<span style=3D"color:=
rgb(148,85,141)">self</span>, <span style=3D"font-style:italic">channel</sp=
an>, <span style=3D"font-style:italic">reason</span>)<span style=3D"font-we=
ight:bold">:</span></pre><pre style=3D"background-color:rgb(248,248,255);co=
lor:rgb(0,0,0);font-family:Menlo;font-size:9pt"><span style=3D"font-weight:=
bold"> t =3D </span><span style=3D"font-size:9pt;font-weight:bold"> </sp=
an><span style=3D"font-size:9pt">asyncio.</span><span style=3D"font-size:9p=
t;color:rgb(153,0,0);font-weight:bold">all_tasks</span><span style=3D"font-=
size:9pt">(asyncio.</span><span style=3D"font-size:9pt;color:rgb(153,0,0);f=
ont-weight:bold">get_event_loop</span><span style=3D"font-size:9pt">())</sp=
an></pre><pre style=3D"background-color:rgb(248,248,255);color:rgb(0,0,0);f=
ont-family:Menlo;font-size:9pt"><span style=3D"font-size:9pt"> print(&qu=
ot;pending tasks ", len(t))</span></pre></div><div>The above does show=
s the list of pending tasks.=C2=A0 I am wondering if you have any advice on=
how to kill these coroutines?=C2=A0</div><div>Also, I apologize if this is=
the wrong community to ask and if I should post it to asyncio community?</=
div><div>Thanks for all the help.</div><div>Regards,</div><div>Waqar</div><=
div><br></div><div><br></div><div><br></div><div><br></div></div><br><div c=
lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Aug 3, 2=
019 at 3:56 PM Glyph <<a href=3D"mailto:[email protected]">glyph@t=
wistedmatrix.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex"><div style=3D"overflow-wrap: break-word;"><br><div><br><blo=
ckquote type=3D"cite"><div>On Aug 2, 2019, at 4:31 PM, Waqar Khan <<a hr=
ef=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>>=
wrote:</div><br class=3D"gmail-m_-758423342056639834Apple-interchange-newl=
ine"><div><div dir=3D"ltr">Hi,<div>=C2=A0 I have a twisted server. And I ha=
ve been seeing this annoying issue.</div><div>Normally. when i develop and =
test it out. everything is fine..<br>But then I try to loadtest is via=C2=
=A0<a href=3D"https://locust.io/" target=3D"_blank">https://locust.io/</a><=
/div><div><br></div><div>Again, everything is fine.. until I "stop&quo=
t; the test.</div><div>Then, I see this<br>'Traceback (most recent call=
last):\n =C2=A0File "/usr/local/Cellar/python/3.7.1/Frameworks/Python=
.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 88, in =
_run\n =C2=A0 =C2=A0self._context.run(self._callback, *self._args)\n =C2=A0=
File "/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py=
", line 827, in adapt\n =C2=A0 =C2=A0adapt.actual.callback(extracted)\=
n =C2=A0File "/usr/local/lib/python3.7/site-packages/twisted/internet/=
defer.py", line 460, in callback\n =C2=A0 =C2=A0self._startRunCallback=
s(result)\n =C2=A0File "/usr/local/lib/python3.7/site-packages/twisted=
/internet/defer.py", line 568, in _startRunCallbacks\n =C2=A0 =C2=A0se=
lf._runCallbacks()\n--- <exception caught here> ---\n =C2=A0File &quo=
t;/usr/local/lib/python3.7/site-packages/twisted/internet/defer.py", l=
ine 654, in _runCallbacks\n =C2=A0 =C2=A0current.result =3D callback(curren=
t.result, *args, **kw)\n =C2=A0File=C2=A0</div><div>....</div><div>=C2=A0Fi=
le "/usr/local/lib/python3.7/site-packages/twisted/web/server.py"=
, line 238, in write\n =C2=A0 =C2=A0http.Request.write(self, data)\n =C2=A0=
File "/usr/local/lib/python3.7/site-packages/twisted/web/http.py"=
, line 1118, in write\n =C2=A0 =C2=A0self.channel.writeHeaders(version, cod=
e, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object h=
as no attribute \'writeHeaders\'\n'<br></div><div><br></div><di=
v><br></div><div>I found this similar bug report:=C2=A0<a href=3D"https://g=
ithub.com/buildbot/buildbot/issues/4045" target=3D"_blank">https://github.c=
om/buildbot/buildbot/issues/4045</a></div><div>But I am using=C2=A019.2.1 t=
wisted version..</div></div></div></blockquote><div><br></div><div>There is=
a prerelease version, with this bug fixed, that is awaiting final release =
upload right now; can you try with=C2=A0Twisted=3D=3D19.7.0rc1 ?=C2=A0 That=
should fix this issue.=C2=A0 If not, then we have some investigating to do=
:-).</div><div><br></div><div>-g</div></div><div><br></div><div>-g</div></=
div>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Twist=
[email protected]</a><br>
<a href=3D"https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-pytho=
n" rel=3D"noreferrer" target=3D"_blank">https://twistedmatrix.com/cgi-bin/m=
ailman/listinfo/twisted-python</a><br>
</blockquote></div>
--000000000000beb9c2058f5430ab--
--===============0301031311417894032==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC1Q
eXRob24gbWFpbGluZyBsaXN0ClR3aXN0ZWQtUHl0aG9uQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBz
Oi8vdHdpc3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtcHl0
aG9uCg==
--===============0301031311417894032==--