Deepomatic / deepomatic-client-python

Python Client
Other
14 stars 0 forks source link

Two many opened connections when using a unique client object #21

Closed PierreLesouhaitier closed 5 years ago

PierreLesouhaitier commented 6 years ago
maingoh commented 6 years ago

This is weird as the code of requests open and close the connection right after https://github.com/requests/requests/blob/ef88b9faa6d73bc83a07ddebc424c551d2ee671c/requests/api.py#L57

Maybe the connection is kept open at the internet router level ? It is better to use session in any case https://stackoverflow.com/questions/18466079/can-i-change-the-connection-pool-size-for-pythons-requests-module

PierreLesouhaitier commented 6 years ago
maingoh commented 6 years ago

I think you were not using the PR. We just made a new release. You can install it with

pip install https://github.com/Deepomatic/deepomatic-client-python/archive/v0.7.3.tar.gz

Basically with netstat | grep http | grep $ipofserver you will see it increases at the beggining and then get stable. This is because the keep alive connections are closed every 100 requests. Without session its one connection per request. So you can see that you will just get one ESTABLISHED connection per process and some TIME_WAIT connections that have been closed on server side. Also I added a less violent retry for polling tasks so connections will be closed less often. On my tests it got stable around 40 dead connections which is ok.

Since you have everything in place if you can test for me with your script that would be nice :)

maingoh commented 5 years ago

Should be fine now since #22. Reopen if there is still a problem. I keep #20 open to confirm with the script.