python - httplib.HTTPConnection timeout: connect vs other blocking calls -
i'm trying use python's httpconnection make long running remote procedure calls (~30 seconds)
httplib.httpconnection(..., timeout=45)
solves this. however, means failed connection attempts cause painfully long wait. can independently control read , connect timeouts socket -- can when using httpconnection?
i understand not waiting send request, if deal connection failure first, wont have wait, i.e. don't include timeout parameter first request, following:
httplib.httpsconnection ('url' ) headers ={'connection' : 'keep-alive'} conn.request("request blank", headers) #dummy request open conn , keep alive dummy_response = conn.getresponse() if dummmy_response == 200 or dummy_response == 201: #if ok, work conn conn.request("request real", timeout = 25) else: reconnect. #restart dummy request
just suggestion, can bump question or have answered again.
Comments
Post a Comment