Skip to content

Published Future retrieved from async client is synchronous #3227

@crusaderky

Description

@crusaderky

distributed-2.7.0
Possibly related to #2336.

I'm using an asynchronous client connected to a remote cluster.
A publish_dataset -> get_dataset roundtrip on a Future causes it to be attached to a synchronous client.

client = await distributed.Client("localhost:8786", asynchronous=True)
a, = client.compute([delayed(1, pure=True)])
print(a)  # <Future: status: pending, key: int-62645d78d66e2508256b7ab60a38b944>
print(a.result())  # <coroutine object Future._result at 0x11ad10dd0>
print(await a)  # 1

await client.publish_dataset(foo=a)
b = await client.get_dataset("foo")

print(b)  # <Future: status: pending, key: int-62645d78d66e2508256b7ab60a38b944>
print(client.asynchronous, b.client.asynchronous) # True, False
print(b.result())  # 1
print(await b)  # AttributeError: 'int' object has no attribute '__await__'

Switching to a LocalCluster weirdly makes the issue disappear.

Workarounds:

  • Force b.client = client
  • Use client.gather([b]) instead, which (involuntarily?) seems to ignore b.client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions