server: sleep 1ms after calling component close methods

This allows any cancelled tasks to run through the eventloop
before loop.stop() is called.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan committed 2022-06-28 19:21:21 -04:00
1 parent 09550af466
commit 0a0993f9e0
1 file changed
+2
+2
View File
@@ -373,6 +373,8 @@ class Server:
except Exception:
logging.exception(
f"Error executing 'close()' for component: {name}")
# Allow cancelled tasks a chance to run in the eventloop
await asyncio.sleep(.001)
self.exit_reason = exit_reason
self.event_loop.remove_signal_handler(signal.SIGTERM)