From 1e5ee8c2d7cc0de82e5ee15deb5ee47e927822fe Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Sun, 3 Oct 2021 12:13:23 +0200 Subject: [PATCH] L2SS-412: Added comments explaining event loop for AsyncCommClient --- devices/clients/comms_client.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/devices/clients/comms_client.py b/devices/clients/comms_client.py index a44aa024a..00234042b 100644 --- a/devices/clients/comms_client.py +++ b/devices/clients/comms_client.py @@ -152,7 +152,18 @@ class AsyncCommClient(object): def __init__(self, fault_func, event_loop=None): """ + Create an Asynchronous communication client. + fault_func: Function to call to put the device to FAULT if an error is detected. + event_loop: Aysncio event loop to use. If None, a new event loop is created and + run in a separate thread. Only share event loops if any of the functions + executed doesn't stall, as asyncio used a cooperative multitasking model. + + If the executed functions can stall (for a bit), use a dedicated loop to avoid + interfering with other users of the event loop. + + All coroutines need to be executed in this loop, which wil also be stored + as the `event_loop` member of this object. """ self.fault_func = fault_func self.running = False -- GitLab