title: python request: how to loop the request.post in for loop?
body: <p>I'm trying to loop the <code>request.post</code> request in python to post the value to the server, so I'm using the <code>for</code> loop. (The code name is <code>temp-hum-log2.py</code>)</p>
  
  <pre><code>with open('Data_IoT.Input.swift01.5.json', 'r') as readfile:
      data1 = json.load(readfile)
  for info1 in data1:
      with open('a.json', 'w') as outfile:
          json.dump(info1, outfile)
      execfile('ECIES_enc.py')
      with open('b.json', 'r') as editfile:
          data1 = json.load(editfile)
      ecc = data1["ecc"]
      privateKey = data1["Private key"]
      cipher = data1["cipher"]
      otp = data1["otp"]
      payload2 = {"cipher": cipher}
      with open('b.json', 'w') as editfile:
          json.dump(payload2, editfile)
      with open('b.json', 'r') as myfile:
          data2=myfile.read()
      payloadenc = json.loads(data2)
      params2 = {"privateKey" : privateKey, "ecc" : ecc, "otp" :otp}
      r = requests.post(url, json=payloadenc, params = params2, timeout = 10)
  </code></pre>
  
  <p>At first when I didn't add the <code>timeout</code> in <code>request.post</code>, the loop didn't continue because it got stuck at the post request and didn't continue to the next line/loop. So I added the <code>timeout</code> into it, but instead, the timeout just ended the code process entirely </p>
  
  <pre><code>Traceback (most recent call last):
    File "temp-hum-log2.py", line 102, in &lt;module&gt;
      r = requests.post(url, json=payloadenc, params = params2, timeout = 10)
    File "/usr/lib/python2.7/dist-packages/requests/api.py", line 116, in post
      return request('post', url, data=data, json=json, **kwargs)
    File "/usr/lib/python2.7/dist-packages/requests/api.py", line 60, in request
      return session.request(method=method, url=url, **kwargs)
    File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 533, in request
      resp = self.send(prep, **send_kwargs)
    File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 646, in send
      r = adapter.send(request, **kwargs)
    File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 529, in send
      raise ReadTimeout(e, request=request)
  requests.exceptions.ReadTimeout: HTTPConnectionPool(host='35.247.186.59', port=3340): Read timed out. (read timeout=10)
  </code></pre>
  
  <p>for additional information, this is the <code>post</code> method in the server side with Express in Node.js</p>
  
  <pre><code>app.post('/temperature_humidity', function(req, res) {
      startTime = new Date();
      console.log(req.originalUrl);
      temp_hum_json_enc = req.body;
          privateKey = req.query.privateKey;
          ecc = req.query.ecc;
          otp1 = req.query.otp;
          temp_hum_json_enc.privateKey = privateKey;
          temp_hum_json_enc.ecc = ecc;
          temp_hum_json_enc.otp = otp1;
      const data_enc = JSON.stringify(temp_hum_json_enc);
          const data_otp = JSON.stringify(otp1);
      fs.writeFile('b.json', data_enc, function (err) {
        if (err) throw err;
        console.log('Saved!');
      });
      fs.writeFile('otpauth.json', data_otp, function (err) {
        if (err) throw err;
      });
      startTime = new Date();
  });
  </code></pre>
  
  <p>What can I do to make the code loop the post request properly?</p>