Skip to content

Commit 895d02c

Browse files
committed
Update _is_daemon.py
1 parent b3ddc99 commit 895d02c

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

yaqd-core/yaqd_core/_is_daemon.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,27 @@ async def _main(cls, config_filepath, config_file, args=None):
208208
s, lambda s=s: asyncio.create_task(cls.shutdown_all(s, loop))
209209
)
210210

211-
cls.__servers = set()
212-
for section in config_file:
213-
if section == "shared-settings":
214-
continue
215-
try:
216-
config = cls._parse_config(config_file, section, args)
217-
except ValueError as e:
218-
logger.error(str(e))
219-
continue
220-
logger.debug(f"Starting {section} with {config}")
221-
await cls._start_daemon(section, config, config_filepath)
222-
223-
while cls.__servers:
224-
awaiting = cls.__servers
211+
try:
225212
cls.__servers = set()
226-
await asyncio.wait(awaiting)
227-
await asyncio.sleep(1)
228-
loop.stop()
213+
for section in config_file:
214+
if section == "shared-settings":
215+
continue
216+
try:
217+
config = cls._parse_config(config_file, section, args)
218+
except ValueError as e:
219+
logger.error(str(e))
220+
continue
221+
logger.debug(f"Starting {section} with {config}")
222+
await cls._start_daemon(section, config, config_filepath)
223+
224+
while cls.__servers:
225+
awaiting = cls.__servers
226+
cls.__servers = set()
227+
await asyncio.wait(awaiting)
228+
await asyncio.sleep(1)
229+
loop.stop()
230+
except KeyboardInterrupt: # handle windows ctrl+c
231+
await cls.shutdown_all(signal.SIGINT, loop)
229232

230233
@classmethod
231234
async def _start_daemon(cls, name, config, config_filepath):

0 commit comments

Comments
 (0)