File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ class Config(object):
1212 DEFAULT_PORT = "5000"
1313 CORS_HEADERS = "Content-Type"
1414 UPLOAD_FOLDER = "./uploads"
15- DESKTOP_APP = False
1615 REQUEST_COUNTER = 0
1716 LAST_REQUEST_TIME = time .time ()
1817 LAST_PING_TIME = time .time ()
Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ def teardown_request(current_app):
4343
4444
4545def 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,15 +51,19 @@ 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+
63+
64+ def kill_server ():
65+ print ("Server timed out due to inactivity, shutting down..." , flush = True )
66+ os ._exit (0 )
6467
6568
6669def versions (list_packages : list ):
You can’t perform that action at this time.
0 commit comments