-
-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No longer start stopped loops in LoopRunner to allow the use of asyncio.run #6163
Comments
Keeping an eye on this as it will break coiled's implementation of |
I could be missing something, but I don't see the |
We are aware that this may break some users but discussed that a deprecation cycle would not be necessary cc @mrocklin |
@jrbourbeau Whatever version of |
OK, so I should clarify my thinking from before. Certainly we need downstream deployment projects (dask-kubernetes, dask-cloudprovider, etc.) to continue functioning. What I intended to say before is that I don't care about supporting a user-workflow where users say However, if our own downstream code relies on passing |
the use of LoopRunner in dask-kubernetes is incorrect, this test fails because distributed.deploy.Cluster re-assigns the def test_loop(k8s_cluster, release, test_namespace):
from dask_kubernetes import HelmCluster
with Client(nthreads=[]) as client, HelmCluster(
release_name=release, namespace=test_namespace, loop=client.loop
) as cluster:
assert cluster.loop is client.loop # this fails because HelmCluster's parent class replaces the cluster.loop |
cc @jacobtomlinson (regarding loop handling in Dask-Kubernetes) |
Thanks for the heads up (and thanks for the PR in It is likely the asyncio stuff in downstream projects like
In many of these projects I've copy/pasted chunks from |
So a quick clarifier: without |
Do you need more feedback or anything else to move on? |
refs #6163 Passing anything other than `IOLoop.current()` will fail when you try to use the Scheduler anyway: self._lock will be bound to `IOLoop.current().asyncio_loop` aka `asyncio.get_running_loop()`: https://github.com/dask/distributed/blob/fc42dbd89afa4ab6709b197db5c2a14c284e99bf/distributed/scheduler.py#L2923 and start_http_server runs on the IOLoop.current() also: https://github.com/dask/distributed/blob/fc42dbd89afa4ab6709b197db5c2a14c284e99bf/distributed/scheduler.py#L2963
No I don't think so, I'm mostly fixing places in the codebase and tests where a loop that's about to be run is required. rather than deprecating passing loops at all, to LoopRunner, Client, LocalCluster and SpecCluster I now plan on only deprecating passing loops that are not running, eg a loop received from the deprecated so the plan is: loop = IOLoop.current() # deprecated by asyncio and tornado
c = Client(..., loop=loop) # deprecated by distributed
cluster = SomeCluster(..., loop=loop) # deprecated by distributed however if you do need a global loop you would be able use: runner = LoopRunner(asynchronous=False, loop=None)
loop = runner.start()
c = Client(..., loop=loop)
cluster = SomeCluster(..., loop=loop)
runner.stop() but it's preferable to use: with Client(..., loop=None) as c:
with SomeCluster(..., loop=c.loop) as cluster:
... or make your own running loop: async def call(fn):
return fn
with loop_in_thread() as asyncio_loop:
io_loop = asyncio.run_coroutine_threadsafe(coro=call(IOLoop.current), loop=asyncio_loop).result()
with Client(..., loop=io_loop) as c:
with SomeCluster(..., loop=io_loop) as cluster:
... |
* `DeprecationWarning` is being thrown by Dask but should be fixed by dask/distributed#6163 * Temporarily disabling this test for two weeks as to not trigger nightly test failures
* `DeprecationWarning` is being thrown by Dask but should be fixed by dask/distributed#6163 * Temporarily disabling this test for two weeks as to not trigger nightly test failures
The
LoopRunner
is accepting an event loop that has been created externally. This is a pattern that has been deprecated by CPython and our current implementation.Requirements
LoopRunner
no longer accepts event loops but creates and owns them itself.LoopRunner
guarantees that all existingtornado.IOLoop
instances are properly closed if the underlyingasyncio
event loop is stopped when loop is started and stopped without tornado API (e.g.asyncio.run
).More context in #6049
Implementation details
The text was updated successfully, but these errors were encountered: