Skip to content

Instantly share code, notes, and snippets.

@timotta
Created December 5, 2012 00:31
Show Gist options
  • Save timotta/4210699 to your computer and use it in GitHub Desktop.
Save timotta/4210699 to your computer and use it in GitHub Desktop.
geventhttpclient connection pool
from geventhttpclient.url import URL
from geventhttpclient.client import HTTPClient
url = URL("http://musica.com.br/artistas/a/")
http = HTTPClient.from_url(url, connection_timeout=1, concurrency=5)
def get():
print "Getting..."
response = http.get(url.path)
try:
response.read()
finally:
print "Connection pool before release:", http._connection_pool._socket_queue.qsize()
response.release()
print "Connection pool after release:", http._connection_pool._socket_queue.qsize()
print "Initial connection pool: ", http._connection_pool._socket_queue.qsize()
get()
get()
get()
get()
get()
print "Final connection pool: ", http._connection_pool._socket_queue.qsize()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment