@@ -21,29 +21,26 @@ async def main() -> None:
21
21
if actor_input .get ('called_from_another_actor' , False ) is True :
22
22
return
23
23
24
- await asyncio .sleep (1 )
25
24
# Start another run of this actor with timeout set to the time remaining in this actor run
26
- other_run_data = await Actor .start (
25
+ other_run_data = await Actor .call (
27
26
actor_id = Actor .configuration .actor_id or '' ,
28
27
run_input = {'called_from_another_actor' : True },
29
28
timeout = 'RemainingTime' ,
30
29
)
31
-
32
- # To make sure that the actor is started
33
- await asyncio .sleep (5 )
34
-
35
- assert Actor .configuration .timeout_at is not None
36
- assert Actor .configuration .started_at is not None
37
30
assert other_run_data is not None
38
- assert other_run_data .options is not None
31
+ try :
32
+ # To make sure that the actor is started
33
+ await asyncio .sleep (5 )
34
+ assert other_run_data .options is not None
35
+ assert Actor .configuration .timeout_at is not None
36
+ assert Actor .configuration .started_at is not None
39
37
40
- remaining_time_after_actor_start = Actor .configuration .timeout_at - datetime .now (tz = timezone .utc )
38
+ remaining_time_after_actor_start = Actor .configuration .timeout_at - datetime .now (tz = timezone .utc )
41
39
42
- try :
43
40
assert other_run_data .options .timeout > remaining_time_after_actor_start
44
41
assert other_run_data .options .timeout < Actor .configuration .timeout_at - Actor .configuration .started_at
45
42
finally :
46
- # Abort the other actor run after asserting the timeouts
43
+ # Make sure the other actor run is aborted
47
44
await Actor .apify_client .run (other_run_data .id ).abort ()
48
45
49
46
actor = await make_actor (label = 'remaining-timeout' , main_func = main )
@@ -65,28 +62,29 @@ async def main() -> None:
65
62
return
66
63
67
64
await asyncio .sleep (1 )
65
+
68
66
# Start another run of this actor with timeout set to the time remaining in this actor run
69
67
other_run_data = await Actor .call (
70
68
actor_id = Actor .configuration .actor_id or '' ,
71
69
run_input = {'called_from_another_actor' : True },
72
70
timeout = 'RemainingTime' ,
73
71
)
74
72
75
- # To make sure that the actor is started
76
- await asyncio .sleep (5 )
77
-
78
- assert Actor .configuration .timeout_at is not None
79
- assert Actor .configuration .started_at is not None
80
73
assert other_run_data is not None
81
- assert other_run_data .options is not None
74
+ try :
75
+ # To make sure that the actor is started
76
+ await asyncio .sleep (5 )
82
77
83
- remaining_time_after_actor_start = Actor .configuration .timeout_at - datetime .now (tz = timezone .utc )
78
+ assert other_run_data .options is not None
79
+ assert Actor .configuration .timeout_at is not None
80
+ assert Actor .configuration .started_at is not None
81
+
82
+ remaining_time_after_actor_start = Actor .configuration .timeout_at - datetime .now (tz = timezone .utc )
84
83
85
- try :
86
84
assert other_run_data .options .timeout > remaining_time_after_actor_start
87
85
assert other_run_data .options .timeout < Actor .configuration .timeout_at - Actor .configuration .started_at
88
86
finally :
89
- # Abort the other actor run after asserting the timeouts
87
+ # Make sure the other actor run is aborted
90
88
await Actor .apify_client .run (other_run_data .id ).abort ()
91
89
92
90
actor = await make_actor (label = 'remaining-timeout' , main_func = main )
0 commit comments