From 90ec6fcd22c11e82c4290db8b523444b803e588d Mon Sep 17 00:00:00 2001 From: Lyncoln Date: Fri, 23 Oct 2026 22:06:50 -0400 Subject: [PATCH] Introduced per session threading tio prevent session collisions and Connection Reset errors --- core/apirequest/execute.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/core/apirequest/execute.py b/core/apirequest/execute.py index 9a31893..7c2223e 100644 --- a/core/apirequest/execute.py +++ b/core/apirequest/execute.py @@ -1,10 +1,28 @@ import requests +import threading from .request import buildRequest -session = requests.Session() +#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(