Use Current ioloop in SyncWrapper

A new ioloop is created for each SyncWrapper, but is not swapped in
automatically (see make_current=False for Tornado) anymore - this means
that the context manager (current_ioloop) is needed to access that
ioloop for the purposes of the synchronus execution.

Signed-off-by: Joe Groocock <jgroocock@cloudflare.com>
This commit is contained in:
Joe Groocock 2025-01-06 17:44:33 +00:00 committed by Daniel Wozniak
parent f6db09f724
commit dcf37bda37

View file

@ -63,7 +63,8 @@ class SyncWrapper:
self.cls = cls
if loop_kwarg:
kwargs[self.loop_kwarg] = self.io_loop
self.obj = cls(*args, **kwargs)
with current_ioloop(self.io_loop):
self.obj = cls(*args, **kwargs)
self._async_methods = list(
set(async_methods + getattr(self.obj, "async_methods", []))
)