-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathsendrequest.py
More file actions
28 lines (25 loc) · 762 Bytes
/
sendrequest.py
File metadata and controls
28 lines (25 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys
TaskQ5_ROOT= "/home/jsh/TaskQ5-py"
sys.path.insert(0,TaskQ5_ROOT)
from TaskQ5.do_requests import send_request
from nostrclient.log import log
import json
import threading
condition = threading.Condition()
def handle_task(request,response):
def finish_task(data):
nonlocal response
res = json.loads(data["content"])
response['data'] = res['data']
response['status'] = res['status']
response['headers'] = res['headers']
with condition:
condition.notify()
send_request(request,finish_task)
with condition:
ret = condition.wait(timeout=20)
if ret:
return True
log.red("Timeout")
print(request)
return False