mirror of
https://github.com/wassname/ray.git
synced 2026-07-18 12:40:56 +08:00
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:
committed by
Philipp Moritz
parent
4e281ba938
commit
49fe894e22
@@ -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
|
||||
-------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user