44from returns .primitives .reawaitable import ReAwaitable , reawaitable
55
66
7- async def sample_coro ():
8- await anyio .sleep (0.1 )
7+ # Fix for issue with multiple awaits on the same ReAwaitable instance
8+ # causing race conditions: https://github.com/dry-python/returns/issues/2048
9+ async def sample_coro () -> str :
10+ """Sample coroutine for testing."""
11+ await anyio .sleep (1 ) # Increased from 0.1 to reduce chance of random failures
912 return 'done'
1013
1114
12- async def await_helper (awaitable_obj ):
15+ async def await_helper (awaitable_obj ) -> str :
1316 """Helper to await objects in tasks."""
1417 return await awaitable_obj
1518
1619
1720@pytest .mark .anyio
18- async def test_concurrent_awaitable ():
21+ async def test_concurrent_awaitable () -> None :
1922 """Test that ReAwaitable works with concurrent awaits."""
2023 test_target = ReAwaitable (sample_coro ())
2124
@@ -25,11 +28,11 @@ async def test_concurrent_awaitable():
2528
2629
2730@pytest .mark .anyio # noqa: WPS210
28- async def test_reawaitable_decorator ():
31+ async def test_reawaitable_decorator () -> None :
2932 """Test the reawaitable decorator with concurrent awaits."""
3033
31- async def test_coro (): # noqa: WPS430
32- await anyio .sleep (0.1 )
34+ async def test_coro () -> str : # noqa: WPS430
35+ await anyio .sleep (1 ) # Increased from 0.1 to reduce chance of random failures
3336 return "decorated"
3437
3538 decorated = reawaitable (test_coro )
@@ -49,10 +52,10 @@ async def test_coro(): # noqa: WPS430
4952
5053
5154@pytest .mark .anyio
52- async def test_reawaitable_repr ():
55+ async def test_reawaitable_repr () -> None :
5356 """Test the __repr__ method of ReAwaitable."""
5457
55- async def test_func (): # noqa: WPS430
58+ async def test_func () -> int : # noqa: WPS430
5659 return 1
5760
5861 coro = test_func ()
0 commit comments