(timeout: float, *, blocking: bool, already_waited: float)
| 38 | |
| 39 | |
| 40 | def timeout_for_sqlite(timeout: float, *, blocking: bool, already_waited: float) -> int: |
| 41 | if blocking is False: |
| 42 | return 0 |
| 43 | |
| 44 | if timeout == -1: |
| 45 | return _MAX_SQLITE_TIMEOUT_MS |
| 46 | |
| 47 | if timeout < 0: |
| 48 | msg = "timeout must be a non-negative number or -1" |
| 49 | raise ValueError(msg) |
| 50 | |
| 51 | remaining = max(timeout - already_waited, 0) if timeout > 0 else timeout |
| 52 | timeout_ms = int(remaining * 1000) |
| 53 | if timeout_ms > _MAX_SQLITE_TIMEOUT_MS or timeout_ms < 0: |
| 54 | _LOGGER.warning("timeout %s is too large for SQLite, using %s ms instead", timeout, _MAX_SQLITE_TIMEOUT_MS) |
| 55 | return _MAX_SQLITE_TIMEOUT_MS |
| 56 | return timeout_ms |
| 57 | |
| 58 | |
| 59 | class _ReadWriteLockMeta(type): |
no outgoing calls
searching dependent graphs…