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

Function interrupt_once

tests/read_write_helpers.py:104–117  ·  view source on GitHub ↗
(real: Callable[[_T], None], *, before: bool)

Source from the content-addressed store, hash-verified

102
103
104def interrupt_once(real: Callable[[_T], None], *, before: bool) -> Callable[[_T], None]:
105 pending = True
106
107 def call(instance: _T) -> None:
108 nonlocal pending
109 if pending and before:
110 pending = False
111 raise Interrupt
112 real(instance)
113 if pending:
114 pending = False
115 raise Interrupt
116
117 return call
118
119
120class Interrupt(BaseException):

Calls

no outgoing calls