python - requests, cannot assign requested address, out of ports? -


requests.exceptions.connectionerror: ('connection aborted.', error(99, 'cannot assign requested address')) 

i getting error when running multiple processes utilizing python requests library , calling post function api returning (<10ms).

dialing down number of processes running had delaying effect, dialing down 1 process eliminated problem. not solution, did indicate finite resource culprit.

the way resolved issue use requests.session class reuse same connection/session each call in given process.

contrived example:

import requests line in file:   requests.get('http://example.com/api?key={key}'.format(key=line['key'])) 

becomes

import requests requests.session() session:   line in file:     session.get('http://example.com/api?key={key}'.format(key=line['key'])) 

these questions had related advice:

repeated post request causing error "socket.error: (99, 'cannot assign requested address')" python urllib2: cannot assign requested address


Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -