Skip to content

Possible deadlock condition #1030

@jsonjunky

Description

@jsonjunky

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]`

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