Assume that a ray actor is defined as below
@ray.remote
class Buffer:
def __init__(self):
self.memory = np.zeros(10)
def modify_data(self, indices, values):
self.memory[indices] = values
def sample(self, size):
indices = np.random.randint(0, 10, size)
return self.memory[indices]
Is it thread-safe to have other actors call methods of Buffer
without any lock?
The POSIX spec says time is required to be thread safe, and so it is.
No, it is not thread-safe in that sense. If you're appending to the same zip file, you'd need a lock there, or the file contents could get scrambled. If you're appending to different zip files, using separate ZipFile() objects, then you're fine.
No it is not thread-safe.
Yes; by default, only one method will execute on a Ray actor at a time. Ordering from concurrent calls is not guaranteed.
With Ray 0.8, you'll be able to set ActorClass.options(max_concurrency=N)
to override this serial execution guarantee.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With