MCPcopy Create free account
hub / github.com/tox-dev/filelock / timeout_for_sqlite

Function timeout_for_sqlite

src/filelock/_read_write.py:40–56  ·  view source on GitHub ↗
(timeout: float, *, blocking: bool, already_waited: float)

Source from the content-addressed store, hash-verified

38
39
40def 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
59class _ReadWriteLockMeta(type):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…