gawel / WSGIProxy2

A WSGI Proxy with various http client backends
https://wsgiproxy2.readthedocs.org/en/latest/
MIT License
12 stars 17 forks source link

Python 3.4 Resource Warning #11

Closed ronin8600 closed 7 years ago

ronin8600 commented 9 years ago

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.

gawel commented 9 years ago

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

djeebus commented 7 years ago

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.

gawel commented 7 years ago

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

djeebus commented 7 years ago

Oh! Right, I'm talking specifically about this client: https://github.com/gawel/WSGIProxy2/blob/8de5c974d20279e8c7394e5e70441e7502192a8c/wsgiproxy/proxies.py#L74

I fixed it here, would this break anything? https://github.com/gawel/WSGIProxy2/compare/master...djeebus:clean-up-connection

gawel commented 7 years ago

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

djeebus commented 7 years ago

PR incoming! =) Thanks!