Skip to content

Commit 0b84a5f

Browse files
committed
Test that from_thread works when the calling thread is running Trio
1 parent 4286063 commit 0b84a5f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

trio/tests/test_threads.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ def test_run_fn_as_system_task_catched_badly_typed_token():
818818
from_thread_run_sync(_core.current_time, trio_token="Not TrioTokentype")
819819

820820

821-
async def test_from_thread_inside_trio_thread():
821+
async def test_from_thread_inside_same_trio_thread():
822822
def not_called(): # pragma: no cover
823823
assert False
824824

@@ -827,6 +827,15 @@ def not_called(): # pragma: no cover
827827
from_thread_run_sync(not_called, trio_token=trio_token)
828828

829829

830+
async def test_from_thread_inside_different_trio_thread():
831+
target_token = current_trio_token()
832+
833+
async def thread_fn():
834+
return from_thread_run_sync(current_trio_token, trio_token=target_token)
835+
836+
assert target_token == await to_thread_run_sync(_core.run, thread_fn)
837+
838+
830839
@pytest.mark.skipif(buggy_pypy_asyncgens, reason="pypy 7.2.0 is buggy")
831840
def test_from_thread_run_during_shutdown():
832841
save = []

0 commit comments

Comments
 (0)