pcurl and network connection's problem

Prasad, Ramit ramit.prasad at jpmorgan.com.dmarc.invalid
Wed Jul 31 15:32:46 EDT 2013


sam319 wrote:
> I am having problems with pycurl in my threads , when i run it , it does correctly but some times the
> connection has been established but nothing will be downloaded and the threads stay alive without
> doing any thing (especially when the network's speed is slow and has aborted status) .
> 
> i can't use TIMEOUT  because i don't have the max time for downloading
> 
> how can i solve this problem in python

So you want to wait hours/days/years for a failed download? You should always set a 
timeout that is sane. If you anticipate network slowness, then set your timeout to 
something larger like 2-3 minutes. IIRC, the timeout only affects connection
establishment so that will not help out your use case but I want to emphasize
that you always want a timeout to be set. 

Pycurl has an option for LOW_SPEED_LIMIT/LOW_SPEED_TIME which should allow you to set 
a minimum transfer speed which will abort the transfer. This should solve your problem
where the connection is created but nothing is being downloaded.

See: http://stackoverflow.com/questions/4960021/handle-pycurl-hang-on-twitter-streaming-api


Ramit



This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.  



More information about the Python-list mailing list