4
4
from returns .primitives .reawaitable import ReAwaitable , reawaitable
5
5
6
6
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
9
12
return 'done'
10
13
11
14
12
- async def await_helper (awaitable_obj ):
15
+ async def await_helper (awaitable_obj ) -> str :
13
16
"""Helper to await objects in tasks."""
14
17
return await awaitable_obj
15
18
16
19
17
20
@pytest .mark .anyio
18
- async def test_concurrent_awaitable ():
21
+ async def test_concurrent_awaitable () -> None :
19
22
"""Test that ReAwaitable works with concurrent awaits."""
20
23
test_target = ReAwaitable (sample_coro ())
21
24
@@ -25,11 +28,11 @@ async def test_concurrent_awaitable():
25
28
26
29
27
30
@pytest .mark .anyio # noqa: WPS210
28
- async def test_reawaitable_decorator ():
31
+ async def test_reawaitable_decorator () -> None :
29
32
"""Test the reawaitable decorator with concurrent awaits."""
30
33
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
33
36
return "decorated"
34
37
35
38
decorated = reawaitable (test_coro )
@@ -49,10 +52,10 @@ async def test_coro(): # noqa: WPS430
49
52
50
53
51
54
@pytest .mark .anyio
52
- async def test_reawaitable_repr ():
55
+ async def test_reawaitable_repr () -> None :
53
56
"""Test the __repr__ method of ReAwaitable."""
54
57
55
- async def test_func (): # noqa: WPS430
58
+ async def test_func () -> int : # noqa: WPS430
56
59
return 1
57
60
58
61
coro = test_func ()
0 commit comments