Introduced per session threading tio prevent session collisions and Connection Reset errors
This commit is contained in:
@@ -1,10 +1,28 @@
|
||||
import requests
|
||||
import threading
|
||||
|
||||
from .request import buildRequest
|
||||
|
||||
#session = requests.Session()
|
||||
_thread_local = threading.local()
|
||||
|
||||
def getSession():
|
||||
if not hasattr(_thread_local, "session"):
|
||||
session = requests.Session()
|
||||
session.name = threading.current_thread().name
|
||||
_thread_local.session = session
|
||||
|
||||
return _thread_local.session
|
||||
|
||||
|
||||
def executeRequest(action, outputs, resolved):
|
||||
session = getSession()
|
||||
|
||||
print(
|
||||
f"Session {session.name} used by "
|
||||
f"{threading.current_thread().name} thread"
|
||||
)
|
||||
|
||||
request, outputs = buildRequest(action, outputs, resolved)
|
||||
|
||||
response = session.request(
|
||||
|
||||
Reference in New Issue
Block a user