Fix osrf.py_common.process_utils.get_loop() implementation#70
Conversation
On Windows, avoid loops closing during garbage collection and reuse existing ones if possible. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
clalancette
left a comment
There was a problem hiding this comment.
From a naive view, it looks like this shouldn't be necessary; the first time we come in here, the TLS loop_has_been_setup will be False, we'll unconditionally create the ProactorEventLoop, and then set loop_has_been_setup to True. Subsequent invocations should always just use the earlier get_event_loop. Could you explain a bit more why this is needed?
Thing is, the event loop for the current thread may have already been set (e.g. through regular IMHO, this is both a bug in |
omg, wonderful finding 😅 |
Wow, deep stuff. Good find. So am I right in thinking that the main fix here is the close of the old loop and the open of a new |
|
I didn't know the context for the issue. I just assumed the closing in the gc might be an issue if it is actually a singleton but didn't ask after it. Nice to hear the explanation. I agree a comment detailing why this code is like this would be useful. |
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
On Windows, avoid loops closing during garbage collection and reuse existing ones if possible. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
On Windows, avoid loops closing during garbage collection and reuse existing ones if possible.
Connected to ros2/launch#476.