Export remote functions when first used and also fix bug in which rem… (#4844)

* Export remote functions when first used and also fix bug in which remote functions and actor classes are not exported from workers during subsequent ray sessions.

* Documentation update

* Fix tests.

* Fix grammar
This commit is contained in:
Robert Nishihara
2019-05-24 13:44:39 -07:00
committed by Philipp Moritz
parent 4e281ba938
commit 49fe894e22
7 changed files with 66 additions and 52 deletions
-26
View File
@@ -66,32 +66,6 @@ listens for the addition of remote functions to the centralized control state.
When a new remote function is added, the thread fetches the pickled remote
function, unpickles it, and can then execute that function.
Notes and limitations
~~~~~~~~~~~~~~~~~~~~~
- Because we export remote functions as soon as they are defined, that means
that remote functions can't close over variables that are defined after the
remote function is defined. For example, the following code gives an error.
.. code-block:: python
@ray.remote
def f(x):
return helper(x)
def helper(x):
return x + 1
If you call ``f.remote(0)``, it will give an error of the form.
.. code-block:: python
Traceback (most recent call last):
File "<ipython-input-3-12a5beeb2306>", line 3, in f
NameError: name 'helper' is not defined
On the other hand, if ``helper`` is defined before ``f``, then it will work.
Calling a remote function
-------------------------