mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Add python unit test to make sure task in default group doesn't block others. (#20718)
Why are these changes needed? This PR only adds a unit tests for Python concurrency group. Related issue number #20475
This commit is contained in:
parent
722428a657
commit
55cb88f085
1 changed files with 23 additions and 0 deletions
|
@ -4,6 +4,7 @@ import sys
|
|||
import threading
|
||||
import pytest
|
||||
import ray
|
||||
import time
|
||||
|
||||
|
||||
# This tests the methods are executed in the correct eventloop.
|
||||
|
@ -110,5 +111,27 @@ def test_async_methods_in_concurrency_group():
|
|||
assert r1 == r2 == r3
|
||||
|
||||
|
||||
# This case tests that if blocking task in default group blocks
|
||||
# tasks in other groups.
|
||||
# See https://github.com/ray-project/ray/issues/20475
|
||||
def test_default_concurrency_group_does_not_block_others():
|
||||
@ray.remote(concurrency_groups={"my_group": 1})
|
||||
class AsyncActor:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
async def f1(self):
|
||||
time.sleep(10000)
|
||||
return "never return"
|
||||
|
||||
@ray.method(concurrency_group="my_group")
|
||||
def f2(self):
|
||||
return "ok"
|
||||
|
||||
async_actor = AsyncActor.remote()
|
||||
async_actor.f1.remote()
|
||||
assert "ok" == ray.get(async_actor.f2.remote())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main(["-v", __file__]))
|
||||
|
|
Loading…
Add table
Reference in a new issue