# -*- coding: utf-8 -*-

from django.conf import settings
import requests


def send_request(url, data, use_client_id=True, use_client_secret=True):
    import json

    if use_client_id:
        data.update({'client_id': settings.PESTEH_CLIENT_ID})
    if use_client_secret:
        data.update({'client_secret': settings.PESTEH_CLIENT_SECRET})
    params = json.dumps(data)
    resp = requests.post(url, data=params, headers={u"content-type": 'application/json'})
    return json.loads(resp.content)


def generate_user_token(user):
    if not user.is_authenticated():
        return None
    return u"PESTEH-ut-P{}".format(user.id)

@@ -67,16 +67,93 @@
 equests%0A
+from requests.packages.urllib3.connection import ConnectionError%0Aimport time%0A
 %0A%0Adef se
@@ -446,16 +446,82 @@
 s(data)%0A
+%0A    c = 0%0A    while c %3C 100:%0A        c += 1%0A        try:%0A        
     resp
@@ -602,16 +602,109 @@
 json'%7D)%0A
+        except ConnectionError:%0A            time.sleep(0.05)%0A        else:%0A            break%0A
     retu

solve ConnectionError problem with retry