tag:blogger.com,1999:blog-5663931432891696372.post1947041560595922158..comments2023-02-27T06:51:37.517-05:00Comments on Python Quirks: Twisted: Asynchronous HTTP RequestJasonhttp://www.blogger.com/profile/00489496856755184870noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-5663931432891696372.post-6947522446431962482013-05-22T09:12:14.258-04:002013-05-22T09:12:14.258-04:00Thanks for the answer.
Why is it necessary then to...Thanks for the answer.<br />Why is it necessary then to return 'whenFinished' in 'handleResponse'? ectomorphhttps://www.blogger.com/profile/08288259870844710547noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-91876433005666692702013-05-14T09:59:55.170-04:002013-05-14T09:59:55.170-04:00PrinterClient(whenFinished) is a Protocol. r.deli...PrinterClient(whenFinished) is a Protocol. r.deliverBody will make calls on the Protocol object to deliver data (deliverData) and announce that it is finished (connectionLost).Jasonhttps://www.blogger.com/profile/00489496856755184870noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-26196499324602807312013-05-14T07:33:17.330-04:002013-05-14T07:33:17.330-04:00Thanks for this piece of code. I understand what i...Thanks for this piece of code. I understand what is happening there but one part is not really clear to me. May be you can explain this line:<br /><br />r.deliverBody(PrinterClient(whenFinished))<br /><br />How exactly does that work?<br /><br />Thanksectomorphhttps://www.blogger.com/profile/08288259870844710547noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-59571311931655301902013-03-04T10:59:38.184-05:002013-03-04T10:59:38.184-05:00Thanks for the fix, Alex!Thanks for the fix, Alex!Jasonhttps://www.blogger.com/profile/00489496856755184870noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-37536770802250606522013-03-02T23:50:18.389-05:002013-03-02T23:50:18.389-05:00In getPage, should be ['twisted'], rather ...In getPage, should be ['twisted'], rather than 'twisted'].Alexhttps://www.blogger.com/profile/03849375466967362511noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-32912911450851575192012-09-01T01:50:37.222-04:002012-09-01T01:50:37.222-04:00This code is very useful for me. If I want to add ...This code is very useful for me. If I want to add timeout and retry for each request? I have googled, but no good solutions... Young Lu (Jason)https://www.blogger.com/profile/01209689058834983289noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-58777640161325936502011-09-13T10:15:41.658-04:002011-09-13T10:15:41.658-04:00IIRC, the point of the whenFinished Deferreds is t...IIRC, the point of the whenFinished Deferreds is to stop the reactor when all retrievals have completed. Note the callback chain: getPage, handleResponse, whenFinished. The Deferred returned by getPage is added to the DeferredList and doesn't complete until the corresponding whenFinished fires. Hence, reactor.stop is only called after all whenFinished Deferreds have fired.Jasonhttps://www.blogger.com/profile/00489496856755184870noreply@blogger.comtag:blogger.com,1999:blog-5663931432891696372.post-86728287382269141562011-09-10T17:50:57.544-04:002011-09-10T17:50:57.544-04:00Thanks for this blog post. I'm just starting o...Thanks for this blog post. I'm just starting out with Twisted and working through this introduced me to many of the framework's ideas. I wonder if you could answer me on question, why is the whenFinished Deferred, together with self.whenFinished.callback(None) necessary for the PrinterClient to finish? I know that it is in the docs, but I don't understand why... When I remove it the script seems to hang and doesn't finish.David Ahttps://www.blogger.com/profile/01851096344650834212noreply@blogger.com