question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

delayed does not work with local_client

See original GitHub issue

Using delayed to launch tasks from workers does not always work. As reproducible example, I have modified the fibonacci example to use delayed (fib_2 function) instead of submit/gather (fib function).:

from distributed import Client, local_client

def fib(n):
    # this is using the submit idiom, which is working
    if n < 2:
        return n
    else:
        with local_client() as lc:
            a = lc.submit(fib, n - 1)
            b = lc.submit(fib, n - 2)
            a, b = lc.gather([a, b])
            return a + b

def add(a, b):
    return a + b

def fib_2(n):
    # this is using delayed, which is not working
    from dask import delayed
    if n < 2:
        return n
    else:
        with local_client() as lc:
            a = delayed(fib_2)(n - 1)
            b = delayed(fib_2)(n - 2)
            s = delayed(add)(a, b)
            r = s.compute()
            return r

def fib_delayed():
    # get a delayed fib calculation, to make sure the local_client is only spawned from a worker
    from dask import delayed
    d = delayed(fib_2)(10)
    return d

if __name__ == '__main__':
    c = Client()
    fib_d = fib_delayed()
    print(fib_d.dask) # should only have 1 key, the rest is submitted from the worker
    print(fib_d.compute())

running this gives me lots of “Compute failed” errors and a an endless traceback which I’ll omit here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vincentschutcommented, Dec 7, 2016

So this does work when I replace “s.compute()” with “lc.compute(s); r=s.result()”. I always assumed delayed.compute() to be a shortcut of “f=client.compute(d); f.result()” but apparently that is not true within the context of local_client(). Thus I think we can narrow this down to “delayed.compute()” does not work with local_client".

0reactions
GenevieveBuckleycommented, Oct 15, 2021

It looks like things have changed since this issue was opened, I don’t get this problem happening today.

When I run the example with a more recent version of dask/distributed (2021.09.0) I don’t see any errors. (It does tell me that local_client has been moved/renamed to worker_client, but that’s not a problem).

Read more comments on GitHub >

github_iconTop Results From Across the Web

RDS Gateway 60 second delay - TechNet - Microsoft
The client is not happy with the 60 second delay though (understandably), and has asked me to to solve the problem.
Read more >
Bullet spawn (visually) delayed on client - Unity Forum
Spawning locally caused other issues, then other players see delayed bullet position for that client.. maybe because player position if not ...
Read more >
Delay in High Performance scenario · Issue #1478 - GitHub
Our scenario is working fine, but message are arriving with an increasing delay of several minutes to the MQTT broker.
Read more >
Netty: how do I reduce delay between consecutive messages ...
When using a local client the two messages arrive at the same time. If the remote client sends another request before the second...
Read more >
Main Monitor responding delayed when conencting to virtual ...
Now to get to the problem: I'm connecting to the Virtual Desktops over Citrix Storefront which is located in our Intranet of course....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found