<p dir="auto">I have a code that sends GET and POST requests every 10 seconds. But in case there is a delay, the POST requests line itself posts twice. I tried to debug this to the best of my ability and I couldn't but finalize that the library sends the requests twice, or it is something to do with TCP (but then the library should deal with it, right?</p>
<p dir="auto">The code: # this is a general code to give an idea of my implementation</p>
<p dir="auto">import requests<br>
import time<br>
while True:<br>
source = requests.get(url)<br>
result = source.json()<br>
resp = request.post(another_url,json = result,headers)<br>
time.sleep(10)</p>
<p dir="auto">By default, this should be ok, but I don't understand why I get this :</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/11473261/8950185/8dc6db68-35f0-11e5-933c-bf0b7c49c0ef.PNG"><img src="https://cloud.githubusercontent.com/assets/11473261/8950185/8dc6db68-35f0-11e5-933c-bf0b7c49c0ef.PNG" alt="1 4 2_clean_3git" style="max-width: 100%;"></a></p>
<p dir="auto">If it is something to do with my code then please advise me, or otherwise I hope this bug can be fixed.</p>
<p dir="auto">Thank you so much for this awesome library.</p>
<h2 dir="auto">Expected Result</h2>
<p dir="auto">Sending a request with request.get(url, data=data) should return a normal web response.</p>
<h2 dir="auto">Actual Result</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  File &quot;d:\VSWorkspace\MyWebClient.py&quot;, line 64, in query_api
    response = requests.get(url, data=query)
  File &quot;C:\Program Files\Python36\lib\site-packages\requests\api.py&quot;, line 72, in get
    return request('get', url, params=params, **kwargs)
  File &quot;C:\Program Files\Python36\lib\site-packages\requests\api.py&quot;, line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File &quot;C:\Program Files\Python36\lib\site-packages\requests\sessions.py&quot;, line 508, in request
    resp = self.send(prep, **send_kwargs)
  File &quot;C:\Program Files\Python36\lib\site-packages\requests\sessions.py&quot;, line 658, in send
    r.content
  File &quot;C:\Program Files\Python36\lib\site-packages\requests\models.py&quot;, line 823, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File &quot;C:\Program Files\Python36\lib\site-packages\requests\models.py&quot;, line 745, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File &quot;C:\Program Files\Python36\lib\site-packages\urllib3\response.py&quot;, line 432, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File &quot;C:\Program Files\Python36\lib\site-packages\urllib3\response.py&quot;, line 601, in read_chunked
    chunk = self._handle_chunk(amt)
  File &quot;C:\Program Files\Python36\lib\site-packages\urllib3\response.py&quot;, line 566, in _handle_chunk
    returned_chunk = self._fp._safe_read(self.chunk_left)
  File &quot;C:\Program Files\Python36\lib\http\client.py&quot;, line 612, in _safe_read
    chunk = self.fp.read(min(amt, MAXAMOUNT))
AttributeError: 'NoneType' object has no attribute 'read'"><pre class="notranslate"><code class="notranslate">  File "d:\VSWorkspace\MyWebClient.py", line 64, in query_api
    response = requests.get(url, data=query)
  File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\requests\api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Program Files\Python36\lib\site-packages\requests\sessions.py", line 658, in send
    r.content
  File "C:\Program Files\Python36\lib\site-packages\requests\models.py", line 823, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "C:\Program Files\Python36\lib\site-packages\requests\models.py", line 745, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "C:\Program Files\Python36\lib\site-packages\urllib3\response.py", line 432, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "C:\Program Files\Python36\lib\site-packages\urllib3\response.py", line 601, in read_chunked
    chunk = self._handle_chunk(amt)
  File "C:\Program Files\Python36\lib\site-packages\urllib3\response.py", line 566, in _handle_chunk
    returned_chunk = self._fp._safe_read(self.chunk_left)
  File "C:\Program Files\Python36\lib\http\client.py", line 612, in _safe_read
    chunk = self.fp.read(min(amt, MAXAMOUNT))
AttributeError: 'NoneType' object has no attribute 'read'
</code></pre></div>
<h2 dir="auto">System Information</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;chardet&quot;: {
    &quot;version&quot;: &quot;3.0.4&quot;
  },
  &quot;cryptography&quot;: {
    &quot;version&quot;: &quot;&quot;
  },
  &quot;idna&quot;: {
    &quot;version&quot;: &quot;2.6&quot;
  },
  &quot;implementation&quot;: {
    &quot;name&quot;: &quot;CPython&quot;,
    &quot;version&quot;: &quot;3.6.4&quot;
  },
  &quot;platform&quot;: {
    &quot;release&quot;: &quot;10&quot;,
    &quot;system&quot;: &quot;Windows&quot;
  },
  &quot;pyOpenSSL&quot;: {
    &quot;openssl_version&quot;: &quot;&quot;,
    &quot;version&quot;: null
  },
  &quot;requests&quot;: {
    &quot;version&quot;: &quot;2.18.4&quot;
  },
  &quot;system_ssl&quot;: {
    &quot;version&quot;: &quot;100020bf&quot;
  },
  &quot;urllib3&quot;: {
    &quot;version&quot;: &quot;1.22&quot;
  },
  &quot;using_pyopenssl&quot;: false
}"><pre class="notranslate"><code class="notranslate">{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.6"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.6.4"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.18.4"
  },
  "system_ssl": {
    "version": "100020bf"
  },
  "urllib3": {
    "version": "1.22"
  },
  "using_pyopenssl": false
}
</code></pre></div>
<p dir="auto">side note: my pylint in Visual Studio Code shows 8 errors in client.py: 6 constants that are undeclared, one global variable that's undeclared, and one index error that looks to be related to not declaring the variable type in the method definition. But I'm using python 3.6.4, so it could just be a compatibility issue in my pylint version.</p>