Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In [1]: from distributed import Executor
- In [2]: e = Executor('127.0.0.1:8786')
- In [3]: e
- Out[3]: <Executor: scheduler="127.0.0.1:8786" processes=2 cores=2>
- In [4]: import socket
- In [5]: e.run(socket.gethostname)
- Out[5]: {'172.20.12.7:53405': 'n1015', '172.20.12.8:53779': 'n1016'}
- In [6]: %%file mod.py
- ...: def hostname():
- ...: return 'the hostname'
- ...:
- Overwriting mod.py
- In [7]: import mod
- In [8]: mod.hostname()
- Out[8]: 'the hostname'
- In [9]: e.run(mod.hostname)
- distributed.utils - ERROR - No module named 'mod'
- e.upload_file('mod.py')
- In [1]: from math import sin
- In [2]: import pickle
- In [3]: pickle.dumps(sin)
- Out[3]: b'x80x03cmathnsinnqx00.'
- In [3]: import mod
- In [4]: import new
- In [5]: def remote(func):
- ...: return new.function(func.func_code, func.func_globals, closure=func.func_closure)
- ...:
- In [6]: e.run(remote(mod.hostname))
- Out[6]: {'tcp://10.0.2.15:44208': 'the hostname'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement