Questions tagged [urllib3]

`urllib3` is a 3rd-party Python HTTP library with thread-safe connection pooling, file post, and more.

urllib3 is a library for python 2 and 3 providing a HTTP API with thread-safe connection pooling, file posting support, redirection handling and retries.

Documentation can be found at https://urllib3.readthedocs.io/en/latest/

760 questions
7
votes
1 answer

Using python Requests library to consume from Twitter's user streams - how to detect disconnection?

I'm trying to use Requests to create a robust way of consuming from Twitter's user streams. So far, I've produced the following basic working example: """ Example of connecting to the Twitter user stream using Requests. """ import sys import…
wintron
  • 187
  • 1
  • 2
  • 9
6
votes
1 answer

Count number of retries for each request

I use package requests together with urllib3.util.retry.Retry() to send tens of thousands of queries. I seek to count the number of queries and the number of necessary attempts until I successfully retrieve the desired data. My goal is to construct…
Jhonny
  • 568
  • 1
  • 9
  • 26
6
votes
1 answer

Python: fetching urllib3 request headers

We are injecting tracing information into request headers of all the http request calls in our API client library which is implemented based on urllib3 def _init_jaeger_tracer(): '''Jaeger tracer initialization''' config = Config( …
6
votes
0 answers

Python requests & urllib3 Retry - How to simulate a ConnectionError from inside the internal retry loop?

Given following example usage: adapter = HTTPAdapter(max_retries=Retry( total=5, backoff_factor=0.1, status_forcelist=[429, 500, 502, 503, 504], method_whitelist=["HEAD", "GET", "OPTIONS"] )) session =…
Kache
  • 15,647
  • 12
  • 51
  • 79
6
votes
2 answers

Max retries exceed with url (Failed to establish a new connection: [Errno 110] Connection timed out)

raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='mycompanyurl.in', port=443): Max retries exceeded with url: /api/v1/issues.json (Caused by…
Ashish_A1
  • 61
  • 1
  • 1
  • 4
6
votes
2 answers

Python urllib3: close idle connection after some time

Is there a way to tell Python urllib3 to not reuse idle connections after some period of time, and instead to close them? Looking in https://urllib3.readthedocs.io/en/latest/reference/index.html#module-urllib3.connectionpool doesn't seem to show…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
6
votes
1 answer

urllib3.exceptions.ProtocolError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))

I am trying to open a website on chrome using Python Selenium chromedriver. Chrome browser is opening (with warnings) and the url is not opening. Version details : Chrome : 68.0.3440.106 selenium : 3.14.0 …
6
votes
1 answer

ModuleNotFoundError: No module named 'urllib3.exceptions'; 'urllib3' is not a package

I'm using the following code to get data from a REST API: import requests import json key = "my service key" api = "http://api.data.go.kr/openapi/pblprfr-event-info-std?serviceKey=", key, "&s_page=1&s_list=100&type=json" r =…
Dr.Dragon
  • 61
  • 1
  • 4
6
votes
2 answers

How to get round the HTTP Error 403: Forbidden with urllib.request using Python 3

Hi not every time but sometimes when trying to gain access to the LSE code I am thrown the every annoying HTTP Error 403: Forbidden message. Anyone know how I can overcome this issue only using standard python modules (so sadly no beautiful…
JoeTilsed
  • 111
  • 1
  • 1
  • 4
6
votes
2 answers

urllib3 - Failed to establish a new connection: [Errno 111]

I am working in the code modifications on my local setup of openstack Designate. Actually it was working fine before. But now I am trying to execute the same command which was working fine before. Unfortunately now for the same command, I am getting…
iamnewuser
  • 360
  • 1
  • 4
  • 16
6
votes
2 answers

How to get urllib3 and requests working with jython 2.7 beta 1?

Smart folks, I would like to use the awesome requests module in my jython program. It installs and runs just fine in python but I cannot get it to install in jython. I have tried both Jython 2.7a2 and 2.7b1 on mac and ubuntu and get the same errors…
Gautam M
  • 777
  • 1
  • 6
  • 7
6
votes
0 answers

Using urllib3 or requests and Celery

We have a script that downloads documents from various sources periodically. I'm going to move this over to celery, but while doing so, I wanted to take advantage of connection pooling at the same time, but I wasn't sure how to go about it. My…
James R
  • 4,571
  • 3
  • 30
  • 45
5
votes
2 answers

urllib3 HTTPResponse.read() returns empty bytes

I'm trying to read a website's content but I get an empty bytes object, b''. import urllib3 from urllib3 import PoolManager urllib3.disable_warnings() https = PoolManager() r = https.request('GET',…
sef sf
  • 117
  • 1
  • 8
5
votes
1 answer

How to use urllib3.Retry?

I have found next example def prepare_retry_requester(retries: int = 5, forcelist: List = (503,)) -> requests.Session: requester = requests.Session() retry = urllib3.Retry(total=retries, backoff_factor=1, status_forcelist=forcelist) for…
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88
5
votes
0 answers

Statically built python code cannot resolve DNS names

I'm trying to deploy code to a server to which I don't have root access. So the solution I was thinking was to deploy using pyinstaller and staticx. My code runs in python 3.7, in a nutshell, does something like: import requests response =…
JuanXarg
  • 428
  • 2
  • 11