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

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

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -