This repository was archived by the owner on Mar 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 5
5
"""
6
6
import argparse
7
7
import configparser
8
+ import enum
8
9
import fcntl
9
10
import gc
10
11
import importlib
20
21
import warnings
21
22
22
23
from dataclasses import dataclass
24
+ from enum import Enum
23
25
from types import FrameType
24
26
from typing import Any
25
27
from typing import Callable
34
36
from gevent .server import StreamServer
35
37
36
38
from baseplate import Baseplate
39
+ from baseplate .lib import warn_deprecated
37
40
from baseplate .lib .config import Endpoint
38
41
from baseplate .lib .config import EndpointConfiguration
39
42
from baseplate .lib .config import Optional as OptionalConfig
47
50
logger = logging .getLogger (__name__ )
48
51
49
52
53
+ class ServerLifecycle (Enum ):
54
+ RUNNING = enum .auto ()
55
+ SHUTTING_DOWN = enum .auto ()
56
+
57
+
50
58
@dataclass
51
59
class ServerState :
52
- shutting_down : bool = False
60
+ state : ServerLifecycle = ServerLifecycle .RUNNING
61
+
62
+ @property
63
+ def shutting_down (self ) -> bool :
64
+ warn_deprecated ("SERVER_STATE.shutting_down is deprecated in favor of SERVER_STATE.state" )
65
+ return self .state == ServerLifecycle .SHUTTING_DOWN
53
66
54
67
55
68
SERVER_STATE = ServerState ()
@@ -266,7 +279,7 @@ def load_app_and_run_server() -> None:
266
279
try :
267
280
shutdown_event .wait ()
268
281
269
- SERVER_STATE .shutting_down = True
282
+ SERVER_STATE .state = ServerLifecycle . SHUTTING_DOWN
270
283
271
284
if cfg .drain_time :
272
285
logger .debug ("Draining inbound requests..." )
You can’t perform that action at this time.
0 commit comments