gawel / WSGIProxy2

A WSGI Proxy with various http client backends

Home Page:https://wsgiproxy2.readthedocs.org/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python 3.4 Resource Warning

ronin8600 opened this issue · comments

I'm getting a resource warning (socket not being closed) when using WSGIProxy2 with bottle.

It looks like the connection is not being explicitly closed in HttpClient.call. I tried adding a 'conn.close()' before the return and it appears to have fixed the warning.

The thing is that when you need a "Keep-Alive" Connection you don't want to close it

I'm running into this error as well. It seems like the "Keep-Alive" header doesn't apply here. The conn object is being thrown away after use, so there's no way to submit a second request. Or am I reading HttpClient.__call__ wrong? The conn.close() befor return solves the error for me as well.

It depend which client your using. It may be true with the one based on python builtin but not with requests/urllib3

Oh! Right, I'm talking specifically about this client:

conn = ConnClass('%s:%s' % (host, port))

I fixed it here, would this break anything? master...djeebus:clean-up-connection

I guess it's fine if the tests pass. PR welcome :)

PR incoming! =) Thanks!