1
1
import asyncio
2
2
import math
3
3
import time
4
- from datetime import datetime
4
+ from datetime import datetime , timezone
5
5
from typing import Dict , Optional
6
6
7
7
from ..._errors import ApifyApiError
@@ -20,7 +20,7 @@ class ActorJobBaseClient(ResourceClient):
20
20
"""Base sub-client class for actor runs and actor builds."""
21
21
22
22
def _wait_for_finish (self , wait_secs : Optional [int ] = None ) -> Optional [Dict ]:
23
- started_at = datetime .now ()
23
+ started_at = datetime .now (timezone . utc )
24
24
should_repeat = True
25
25
job : Optional [Dict ] = None
26
26
seconds_elapsed = 0
@@ -38,7 +38,7 @@ def _wait_for_finish(self, wait_secs: Optional[int] = None) -> Optional[Dict]:
38
38
)
39
39
job = _parse_date_fields (_pluck_data (response .json ()))
40
40
41
- seconds_elapsed = math .floor (((datetime .now () - started_at ).total_seconds ()))
41
+ seconds_elapsed = math .floor (((datetime .now (timezone . utc ) - started_at ).total_seconds ()))
42
42
if (
43
43
ActorJobStatus (job ['status' ])._is_terminal or (wait_secs is not None and seconds_elapsed >= wait_secs )
44
44
):
@@ -77,7 +77,7 @@ class ActorJobBaseClientAsync(ResourceClientAsync):
77
77
"""Base async sub-client class for actor runs and actor builds."""
78
78
79
79
async def _wait_for_finish (self , wait_secs : Optional [int ] = None ) -> Optional [Dict ]:
80
- started_at = datetime .now ()
80
+ started_at = datetime .now (timezone . utc )
81
81
should_repeat = True
82
82
job : Optional [Dict ] = None
83
83
seconds_elapsed = 0
@@ -95,7 +95,7 @@ async def _wait_for_finish(self, wait_secs: Optional[int] = None) -> Optional[Di
95
95
)
96
96
job = _parse_date_fields (_pluck_data (response .json ()))
97
97
98
- seconds_elapsed = math .floor (((datetime .now () - started_at ).total_seconds ()))
98
+ seconds_elapsed = math .floor (((datetime .now (timezone . utc ) - started_at ).total_seconds ()))
99
99
if (
100
100
ActorJobStatus (job ['status' ])._is_terminal or (wait_secs is not None and seconds_elapsed >= wait_secs )
101
101
):
0 commit comments