[Twisted-web] twisted web client
Laurens Van Houtven
_ at lvh.io
Thu Jun 13 08:34:06 MDT 2013
Hi Sergey,
Several points:
1. Making a new factory for each *client* connection isn't unusual -- just
for servers.
2. The API you probably want to use is twisted.web.client.Agent.
3. You could do something like this (I wrote no tests for this!)
def timeURL(agent, url):
return agent.get(url).addCallback(_responseReceived, time.time(), url)
def _responseReceived(response, startTime, url):
elapsed = time.time() - startTime
print "Elapsed for {}: {}s".format(url, elapsed)
# Note: response received gets called before the entire body is received
... or you could wrap that startTime and URL state in an object, of course
:-)
hope to help
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-web/attachments/20130613/f6c0f69f/attachment.html>
More information about the Twisted-web
mailing list