mirror of
https://github.com/vale981/ray
synced 2025-03-10 13:26:39 -04:00
26 lines
380 B
Python
26 lines
380 B
Python
![]() |
import ray
|
||
|
import requests
|
||
|
|
||
|
ray.init()
|
||
|
|
||
|
|
||
|
@ray.remote
|
||
|
class Counter:
|
||
|
def __init__(self):
|
||
|
self.counter = 0
|
||
|
|
||
|
def inc(self):
|
||
|
self.counter += 1
|
||
|
|
||
|
def get_counter(self):
|
||
|
return self.counter
|
||
|
|
||
|
|
||
|
counter = Counter.remote()
|
||
|
|
||
|
for _ in range(5):
|
||
|
ray.get(counter.inc.remote())
|
||
|
print(ray.get(counter.get_counter.remote()))
|
||
|
|
||
|
print(requests.__version__)
|