Skip to content

Freezes when running in another process #2249

@SuJiaKuan

Description

@SuJiaKuan

When I start a local cluster, scatter variables and submit a task through client, it works fine. But if I allocate other process to scatter through client, the process freezes at this function call and never returns. How to solve the problem? Is it a bug?

Python version: 3.6.5
Dask version: 0.18.0

Here is my code:

from multiprocessing import Process

from dask.distributed import LocalCluster
from dask.distributed import Client
from dask.distributed import get_client


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


def another_process():
    client = get_client()
    a = client.scatter(3) # Freeze here.
    b = client.scatter(4)
    result = client.submit(add, a, b)
    print(result.result())


def main():
    cluster = LocalCluster(n_workers=1)

    with Client(cluster) as client:
        a = client.scatter(3)
        b = client.scatter(4)
        result = client.submit(add, a, b)
        print(result.result()) # Works fine, outputs 7.

        process = Process(target=another_process)
        process.daemon = True
        process.start()
        process.join()

if __name__ == '__main__':
    main()

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