# Path: arq/constants.py

# 
# Path: arq/utils.py
# def ms_to_datetime(unix_ms: int) -> datetime:
#     return datetime.fromtimestamp(unix_ms / 1000, tz=timezone.utc)
# 
# async def poll(step: float = 0.5) -> AsyncGenerator[float, None]:
#     loop = asyncio.get_event_loop()
#     start = loop.time()
#     while True:
#         before = loop.time()
#         yield before - start
#         after = loop.time()
#         wait = max([0, step - after + before])
#         await asyncio.sleep(wait)
# 
# def timestamp_ms() -> int:
#     return as_int(time() * 1000)


import asyncio
import logging
import pickle
import warnings
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Any, Callable, Dict, Optional, Tuple
from redis.asyncio import Redis
from .constants import abort_jobs_ss, default_queue_name, in_progress_key_prefix, job_key_prefix, result_key_prefix
from .utils import ms_to_datetime, poll, timestamp_ms

    def __init__(
        self,
        job_id: str,
        redis: Redis,
        _queue_name: str = default_queue_name,
        _deserializer: Optional[Deserializer] = None,
    ):
        self.job_id = job_id
        self._redis = redis
        self._queue_name = _queue_name
        self._deserializer = _deserializer

    async def result(
        self, timeout: Optional[float] = None, *, poll_delay: float = 0.5, pole_delay: float = None
    ) -> Any:
        """
        Get the result of the job, including waiting if it's not yet available. If the job raised an exception,
        it will be raised here.

        :param timeout: maximum time to wait for the job result before raising ``TimeoutError``, will wait forever
        :param poll_delay: how often to poll redis for the job result
        :param pole_delay: deprecated, use poll_delay instead
        """
        if pole_delay is not None:
            warnings.warn(
                '"pole_delay" is deprecated, use the correct spelling "poll_delay" instead', DeprecationWarning
            )
            poll_delay = pole_delay


# Path: arq/constants.py

# 
# Path: arq/utils.py
# def ms_to_datetime(unix_ms: int) -> datetime:
#     return datetime.fromtimestamp(unix_ms / 1000, tz=timezone.utc)
# 
# async def poll(step: float = 0.5) -> AsyncGenerator[float, None]:
#     loop = asyncio.get_event_loop()
#     start = loop.time()
#     while True:
#         before = loop.time()
#         yield before - start
#         after = loop.time()
#         wait = max([0, step - after + before])
#         await asyncio.sleep(wait)
# 
# def timestamp_ms() -> int:
#     return as_int(time() * 1000)


# Path: arq/jobs.py
import asyncio
import logging
import pickle
import warnings
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Any, Callable, Dict, Optional, Tuple
from redis.asyncio import Redis
from .constants import abort_jobs_ss, default_queue_name, in_progress_key_prefix, job_key_prefix, result_key_prefix
from .utils import ms_to_datetime, poll, timestamp_ms


    def __init__(
        self,
        job_id: str,
        redis: Redis,
        _queue_name: str = default_queue_name,
        _deserializer: Optional[Deserializer] = None,
    ):
        self.job_id = job_id
        self._redis = redis
        self._queue_name = _queue_name
        self._deserializer = _deserializer

    async def result(
        self, timeout: Optional[float] = None, *, poll_delay: float = 0.5, pole_delay: float = None
    ) -> Any:
        """
        Get the result of the job, including waiting if it's not yet available. If the job raised an exception,
        it will be raised here.

        :param timeout: maximum time to wait for the job result before raising ``TimeoutError``, will wait forever
        :param poll_delay: how often to poll redis for the job result
        :param pole_delay: deprecated, use poll_delay instead
        """
        if pole_delay is not None:
            warnings.warn(
                '"pole_delay" is deprecated, use the correct spelling "poll_delay" instead', DeprecationWarning
            )
            poll_delay = pole_delay


        async for delay in poll(poll_delay):