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:
Qing Wang 2021-11-26 21:10:49 +08:00 committed by GitHub
parent 722428a657
commit 55cb88f085
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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__]))