Reputation: 11
I am trying to run the following code. It works if executed in a shell but crashes if executed as macro (py macro.py). Please could you tell me what's wrong. Thank you
import os
import sys
import dask
from dask.distributed import Client
def inc(x):
return x + 1
def add(x, y):
return x + y
client = Client(n_workers=2, threads_per_worker=2, memory_limit='1GB')
a = client.submit(inc, 10)
b = client.submit(inc, 20)
print(a.result())
print(b.result())
Upvotes: 0
Views: 1253
Reputation: 57271
This is a problem with running scripts that create processes. You need to create your Client
object within the if __name__ == "__main__":
block
See the answer in where to put freeze_support() in a Python script? for more information.
Upvotes: 1