html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/4406#issuecomment-785432974,https://api.github.com/repos/pydata/xarray/issues/4406,785432974,MDEyOklzc3VlQ29tbWVudDc4NTQzMjk3NA==,1828519,2021-02-24T22:42:15Z,2021-02-24T22:42:15Z,CONTRIBUTOR,"I'm having a similar issue to what is described here, but I'm seeing it even when I'm not rewriting an output file (although it is an option in my code). I have a delayed function that is calling `to_netcdf` and seem to run into some race condition where I get the same deadlock as the original poster. It seems highly dependent on the number of dask tasks and the number of workers. I *think* I've gotten around it for now by having my delayed function return the Dataset it is working on and then calling `to_dataset` later. My problem is I have cases where I might not want to write the file so my delayed function returns `None`. To handle this I need to pre-compute my delayed functions before calling `to_dataset` since I don't think there is a way to pass something to `to_dataset` so it doesn't create a file. With the original code it happened quite a bit but was part of a much larger application so I can't really get a MWE together. Just wanted to mention it here as another data point (to_netcdf inside a Delayed function may not work 100% of the time).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,694112301