Skip to content

Commit 0d7b2ae

Browse files
committed
gh-2985: Fixed mixins.startup.serve UnboundLocalError.
1 parent da1c646 commit 0d7b2ae

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

sanic/mixins/startup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ def serve(
10331033

10341034
socks = []
10351035
sync_manager = Manager()
1036+
worker_state: Mapping[str, Any] = {"state": "NONE"}
10361037
setup_ext(primary)
10371038
exit_code = 0
10381039
try:
@@ -1056,7 +1057,7 @@ def serve(
10561057
]
10571058
primary_server_info.settings["run_multiple"] = True
10581059
monitor_sub, monitor_pub = Pipe(True)
1059-
worker_state: Mapping[str, Any] = sync_manager.dict()
1060+
worker_state = sync_manager.dict()
10601061
kwargs: Dict[str, Any] = {
10611062
**primary_server_info.settings,
10621063
"monitor_publisher": monitor_pub,

setup.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Sanic
33
"""
4+
45
import codecs
56
import os
67
import re
@@ -59,7 +60,9 @@ def str_to_bool(val: str) -> bool:
5960

6061
with open_local(["sanic", "__version__.py"], encoding="latin1") as fp:
6162
try:
62-
version = re.findall(r"^__version__ = \"([^']+)\"\r?$", fp.read(), re.M)[0]
63+
version = re.findall(
64+
r"^__version__ = \"([^']+)\"\r?$", fp.read(), re.M
65+
)[0]
6366
except IndexError:
6467
raise RuntimeError("Unable to determine version.")
6568

@@ -94,7 +97,9 @@ def str_to_bool(val: str) -> bool:
9497
"entry_points": {"console_scripts": ["sanic = sanic.__main__:main"]},
9598
}
9699

97-
env_dependency = '; sys_platform != "win32" ' 'and implementation_name == "cpython"'
100+
env_dependency = (
101+
'; sys_platform != "win32" ' 'and implementation_name == "cpython"'
102+
)
98103
ujson = "ujson>=1.35" + env_dependency
99104
uvloop = "uvloop>=0.15.0" + env_dependency
100105
types_ujson = "types-ujson" + env_dependency

0 commit comments

Comments
 (0)