keep-alive

Is it ok to keep TCP connections alive throughout the serving time?

Is it ok to keep TCP connections alive throughout the serving time? Question: I’m making a socket TCP server with python that handles multiple connections simultaneously. so I defined a dictionary to hold the clients socket addresses, so I could access them and traffic the information between the clients easily. but I wander if there …

Total answers: 1

Reusing connections in Django with Python Requests

Reusing connections in Django with Python Requests Question: What’s the correct way of reusing Python Requests connections in Django across multiple HTTP requests. That’s what I’m doing currently: import requests def do_request(data): return requests.get(‘http://foo.bar/’, data=data, timeout=4) def my_view1(request) req = do_request({x: 1}) … def my_view2(request) req = do_request({y: 2}) … So, I have one function …

Total answers: 2

python requests module and connection reuse

python requests module and connection reuse Question: I am working with python’s requests module for HTTP communication, and I am wondering how to reuse already-established TCP connections? The requests module is stateless and if I repeatedly call get for the same URL, wouldn’t it create a new connection each time? Thanks!! Asked By: gmemon || …

Total answers: 2

Python urllib2 with keep alive

Python urllib2 with keep alive Question: How can I make a “keep alive” HTTP request using Python’s urllib2? Asked By: ibz || Source Answers: Use the urlgrabber library. This includes an HTTP handler for urllib2 that supports HTTP 1.1 and keepalive: >>> import urllib2 >>> from urlgrabber.keepalive import HTTPHandler >>> keepalive_handler = HTTPHandler() >>> opener …

Total answers: 7