File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 31
31
32
32
logger = structlog .get_logger ()
33
33
34
+ # holder for strong references to pending tasks; remove when the minimum CPython version is one with PR#121264
35
+ background_tasks = set ()
36
+
34
37
35
38
def parse_args (argv : Sequence [str ] | None ) -> argparse .Namespace :
36
39
"""Parse and return the parsed command line arguments."""
@@ -92,13 +95,17 @@ async def start_servers(config: configparser.ConfigParser) -> None:
92
95
ircserver = IRCServer (config ["irc" ])
93
96
irc_coro = ircserver .serve ()
94
97
irc_task = asyncio .create_task (irc_coro )
98
+ background_tasks .add (irc_task )
99
+ irc_task .add_done_callback (background_tasks .discard )
95
100
else :
96
101
logger .critical ('Invalid configuration, missing section "irc"' )
97
102
raise SystemExit (- 1 )
98
103
99
104
if "rc2udp" in config :
100
105
rc2udp_coro = RC2UDPServer (config ["rc2udp" ], ircserver ).serve ()
101
- rc2udp_task = asyncio .create_task (rc2udp_coro ) # noqa: F841 pylint: disable=unused-variable
106
+ rc2udp_task = asyncio .create_task (rc2udp_coro )
107
+ background_tasks .add (rc2udp_task )
108
+ rc2udp_task .add_done_callback (background_tasks .discard )
102
109
else :
103
110
logger .warning ("RC2UDP is not enabled in the config; server usefulness may be limited" )
104
111
You can’t perform that action at this time.
0 commit comments