Skip to content

Commit 8db3eef

Browse files
fix(server timeout): timeout 0 = infinite
1 parent 1c69155 commit 8db3eef

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/opengeodeweb_back/utils_functions.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def teardown_request(current_app):
4343

4444

4545
def kill_task(current_app):
46-
DESKTOP_APP = bool(current_app.config.get("DESKTOP_APP"))
4746
REQUEST_COUNTER = int(current_app.config.get("REQUEST_COUNTER"))
4847
LAST_PING_TIME = float(current_app.config.get("LAST_PING_TIME"))
4948
LAST_REQUEST_TIME = float(current_app.config.get("LAST_REQUEST_TIME"))
@@ -52,16 +51,20 @@ def kill_task(current_app):
5251
minutes_since_last_request = (current_time - LAST_REQUEST_TIME) / 60
5352
minutes_since_last_ping = (current_time - LAST_PING_TIME) / 60
5453

55-
if (
56-
(
57-
(minutes_since_last_request > MINUTES_BEFORE_TIMEOUT)
58-
and (DESKTOP_APP == False)
59-
)
60-
or (minutes_since_last_ping > MINUTES_BEFORE_TIMEOUT)
61-
) and (REQUEST_COUNTER == 0):
62-
print("Server timed out due to inactivity, shutting down...", flush=True)
63-
os._exit(0)
54+
if (REQUEST_COUNTER > 0):
55+
return
56+
if MINUTES_BEFORE_TIMEOUT == 0:
57+
return
58+
if (minutes_since_last_ping > MINUTES_BEFORE_TIMEOUT):
59+
kill_server()
60+
if (minutes_since_last_request > MINUTES_BEFORE_TIMEOUT):
61+
kill_server()
62+
6463

64+
def kill_server():
65+
print("Server timed out due to inactivity, shutting down...", flush=True)
66+
os._exit(0)
67+
6568

6669
def versions(list_packages: list):
6770
list_with_versions = []

0 commit comments

Comments
 (0)