dask / dask/distributed

Possible deadlock condition

Open
#1,030 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.7k
Forks
778
Avg merge
2h 50m
Merged PRs (30d)
3

Description

Hi,
I keep running into a deadlock (or indefinite wait) in this bit of code in utils.py. the workers plot shows a worker present.

distributed 1.16.1
tornado 4.4.3
dask==0.14.1

`def sync(loop, func, *args, **kwargs):
"""
Run coroutine in loop running in separate thread.
"""
if not loop._running:
try:
return loop.run_sync(lambda: func(*args, **kwargs))
except RuntimeError: # loop already running
pass

e = threading.Event()
main_tid = get_thread_identity()
result = [None]
error = [False]

@gen.coroutine
def f():
try:
if main_tid == get_thread_identity():
raise RuntimeError("sync() called from thread of running loop")
yield gen.moment
result[0] = yield gen.maybe_future(func(*args, **kwargs))
except Exception as exc:
logger.exception(exc)
error[0] = sys.exc_info()
finally:
e.set()

loop.add_callback(f)
**while not e.is_set():
e.wait(1000000)** <------------gets trapped here and never gets out. unless a worker dies or another worker shows up
if error[0]:
six.reraise(*error[0])
else:
return result[0]`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.