Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Waqar Khan
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, i

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Glyph
> On Aug 4, 2019, at 5:57 PM, Waqar Khan wrote: > > 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/Py

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Waqar Khan
Hi Glyph, Here is the minimal version class FooResource(resource.Resource): def render_GET(request): future = asyncio.ensure_future(self.fetch_response(request)) // some async await functions d = Deferred.fromFuture(future) d.addCallback(print_j

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Waqar Khan
Just for sake of completeness: def print_json_response(resp, request): request.write(json.dumps(resp)) request.close() It is this close function which is causing the issue I suspect that somehow the fact that the client has closed the connection, is not being handled. On Sun, A

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Glyph
> On Aug 4, 2019, at 8:43 PM, Waqar Khan wrote: > > Just for sake of completeness: > def print_json_response(resp, request): > request.write(json.dumps(resp)) > request.close() Presumably this line actually says "request.finish()"? This is indeed the problem; just don't call

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Waqar Khan
Ah yes.. That is true.. If I comment out request.finish() (Here is the doc which I tried to followed: https://twistedmatrix.com/documents/13.0.0/web/howto/web-in-60/interrupted.html ) Then actually.. when I try to test out the code... (via curl or like doing requests.get .. to the URI).. it is jus

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Glyph
> On Aug 4, 2019, at 9:04 PM, Waqar Khan wrote: > > Ah yes.. That is true.. > > If I comment out request.finish() (Here is the doc which I tried to followed: > https://twistedmatrix.com/documents/13.0.0/web/howto/web-in-60/interrupted.html > >

Re: [Twisted-Python] self.channel.writeHeaders(version, code, reason, headers)\nbuiltins.AttributeError: \'NoneType\' object has no attribute \'writeHeaders\'\

2019-08-04 Thread Waqar Khan
Hi Glyph, I am not sure I understand. Is there a method/variable in request which keeps a track whether notifyFinish has been fired.. So, I can do something like. if not request.hasFiredNotifyFinish: request.finish() ?? I have sort of able to get around this issue.. though I can't pu