Skip to content

Commit

Permalink
LoopRunner raises for unsupported behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
wence- committed Nov 2, 2022
1 parent 86c15d2 commit b60d5bd
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions distributed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,23 +436,19 @@ def __init__(self, loop=None, asynchronous=False):
if asynchronous:
try:
asyncio.get_running_loop()
except RuntimeError:
warnings.warn(
"Constructing a LoopRunner(asynchronous=True) without a running loop is deprecated",
DeprecationWarning,
stacklevel=2,
)
except RuntimeError as e:
raise RuntimeError(
"Constructing a LoopRunner(asynchronous=True) without a running loop is not allowed"
) from e
self._loop = IOLoop.current()
else:
# We're expecting the loop to run in another thread,
# avoid re-using this thread's assigned loop
self._loop = IOLoop()
else:
if not loop.asyncio_loop.is_running():
warnings.warn(
"Constructing LoopRunner(loop=loop) without a running loop is deprecated",
DeprecationWarning,
stacklevel=2,
raise RuntimeError(
"Constructing LoopRunner(loop=loop) without a running loop is not allowed"
)
self._loop = loop
self._asynchronous = asynchronous
Expand Down

0 comments on commit b60d5bd

Please sign in to comment.