Spaces:
Runtime error
Runtime error
polinaeterna
commited on
Commit
·
2259ea7
1
Parent(s):
7d66c17
use session for perspective
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import requests
|
| 2 |
from collections import Counter
|
| 3 |
from requests.adapters import HTTPAdapter, Retry
|
| 4 |
-
import multiprocessing
|
| 5 |
import os
|
| 6 |
import time
|
| 7 |
import logging
|
|
@@ -23,7 +22,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(level
|
|
| 23 |
|
| 24 |
|
| 25 |
session = requests.Session()
|
| 26 |
-
retries = Retry(total=5, backoff_factor=
|
| 27 |
session.mount('http://', HTTPAdapter(max_retries=retries))
|
| 28 |
|
| 29 |
|
|
@@ -183,7 +182,7 @@ def call_perspective_api(texts_df, column_name, nested_column_name, dataset, con
|
|
| 183 |
}
|
| 184 |
time.sleep(1)
|
| 185 |
try:
|
| 186 |
-
req_response =
|
| 187 |
except Exception as e:
|
| 188 |
print(e)
|
| 189 |
return req_att_scores
|
|
|
|
| 1 |
import requests
|
| 2 |
from collections import Counter
|
| 3 |
from requests.adapters import HTTPAdapter, Retry
|
|
|
|
| 4 |
import os
|
| 5 |
import time
|
| 6 |
import logging
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
session = requests.Session()
|
| 25 |
+
retries = Retry(total=5, backoff_factor=2, status_forcelist=[502, 503, 504])
|
| 26 |
session.mount('http://', HTTPAdapter(max_retries=retries))
|
| 27 |
|
| 28 |
|
|
|
|
| 182 |
}
|
| 183 |
time.sleep(1)
|
| 184 |
try:
|
| 185 |
+
req_response = session.post(PERSPECTIVE_URL, json=data, headers=headers)
|
| 186 |
except Exception as e:
|
| 187 |
print(e)
|
| 188 |
return req_att_scores
|