(
timeout # type: Union[timedelta, float, int]
)
| 81 | |
| 82 | |
| 83 | def to_milliseconds( |
| 84 | timeout # type: Union[timedelta, float, int] |
| 85 | ) -> int: |
| 86 | if timeout and not isinstance(timeout, (timedelta, float, int)): |
| 87 | raise InvalidArgumentException(message=("Excepted timeout to be of type " |
| 88 | f"Union[timedelta, float, int] instead of {timeout}")) |
| 89 | if not timeout: |
| 90 | total_us = 0 |
| 91 | elif isinstance(timeout, timedelta): |
| 92 | total_us = int(timeout.total_seconds() * 1e3) |
| 93 | else: |
| 94 | total_us = int(timeout * 1e3) |
| 95 | |
| 96 | return total_us |
| 97 | |
| 98 | |
| 99 | THIRTY_DAYS_IN_SECONDS = 30 * 24 * 60 * 60 |
no test coverage detected