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.

Await on handle_stream raises missing delete_data await warning

See original GitHub issue

For increased visibility, I’m reposting https://github.com/dask/distributed/pull/3847/files#r443766556 as an issue here:

We have a few tests in dask-cuda that check the behavior of Device<->Host<->Disk spilling and I noticed after the 2.19 release one of them has broken, I managed to track it down to one specific line of code in https://github.com/dask/distributed/blob/44b2358e33a0738c4c70ca96db4242636245e07d/distributed/core.py#L573, introduced by https://github.com/dask/distributed/pull/3847. The test in question happens in https://github.com/rapidsai/dask-cuda/blob/branch-0.15/dask_cuda/tests/test_spill.py#L409-L411, where we assert that the zict dictionaries are empty after deleting cdf2, which is the object being spilled. It seems that this is because we’re not awaiting for Worker.delete_data somewhere, as per the warning below that doesn’t happen if I comment await gen.sleep(0) out:

dask_cuda/tests/test_spill.py::test_cudf_device_spill[params0]
  /datasets/pentschev/miniconda3/envs/r-102-0.14/lib/python3.7/inspect.py:732: RuntimeWarning: coroutine 'Worker.delete_data' was never awaited
    for modname, module in list(sys.modules.items()):

I think that the only place where Worker.delete_data would be called and should be awaited is in https://github.com/dask/distributed/blob/4f878b420b349ee725de5ef64fd5e664dedb8aba/distributed/scheduler.py#L2791-L2800, but I don’t have anything better than my guess at this time because it’s really hard for me to understand all the async black magic. I’m gonna continue trying to figure this out, but any suggestions on how to pinpoint that are appreciated!

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
pentschevcommented, Jun 23, 2020

I was able to write a test where we can reproduce the issue independent of GPUs and dask-cuda, therefore I opened #3922 with the fix suggested by @jakirkham and a test for that.

1reaction
pentschevcommented, Jun 22, 2020

Thanks @jakirkham for looking at that, I actually verified that applying your suggestion things work again:

diff --git a/distributed/worker.py b/distributed/worker.py
index 59cd285d..8bd45394 100644
--- a/distributed/worker.py
+++ b/distributed/worker.py
@@ -1341,7 +1341,7 @@ class Worker(ServerNode):
         info = {"nbytes": {k: sizeof(v) for k, v in data.items()}, "status": "OK"}
         return info

-    async def delete_data(self, comm=None, keys=None, report=True):
+    def delete_data(self, comm=None, keys=None, report=True):
         if keys:
             for key in list(keys):
                 self.log.append((key, "delete"))
@@ -1355,7 +1355,7 @@ class Worker(ServerNode):
             if report:
                 logger.debug("Reporting loss of keys to scheduler")
                 # TODO: this route seems to not exist?
-                await self.scheduler.remove_keys(
+                self.scheduler.remove_keys(
                     address=self.contact_address, keys=list(keys)
                 )
         return "OK"

Possibly the second part can be removed/has to be fixed, as the comment above it suggests. There’s no remove_keys anywhere in this repository.

Happy to file a PR if this change is reasonable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No warning when I forget `await` on an interface method call
If I call the async method directly on the c object, I get a compiler warning. There's potentially a bug here, so I'm...
Read more >
Can we make forgetting an await be an error? #79 - GitHub
The problem is that there's no situation where you need to pass around coroutine objects unless you're implementing a library like trio, but ......
Read more >
Compiler Warning (level 1) CS4014 | Microsoft Learn
The call to the async method starts an asynchronous task. However, because no await operator is applied, the program continues without waiting ...
Read more >
await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
Read more >
await-outside-async / E1142 - Pylint 2.16.0-dev documentation
Emitted when await is used outside an async function. Problematic code: import asyncio def main(): await asyncio.sleep(1) # [await-outside-async].
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