MCPcopy
hub / github.com/python-trio/trio / raiser

Function raiser

src/trio/_core/_tests/test_ki.py:278–297  ·  view source on GitHub ↗
(name: str, record: set[str])

Source from the content-addressed store, hash-verified

276 record.add(name + " ok")
277
278 async def raiser(name: str, record: set[str]) -> None:
279 try:
280 # os.kill runs signal handlers before returning, so we don't need
281 # to worry that the handler will be delayed
282 print("killing, protection =", _core.currently_ki_protected())
283 ki_self()
284 except KeyboardInterrupt:
285 print("raised!")
286 # Make sure we aren't getting cancelled as well as siginted
287 await _core.checkpoint()
288 record.add(name + " raise ok")
289 raise
290 else:
291 print("didn't raise!")
292 # If we didn't raise (b/c protected), then we *should* get
293 # cancelled at the next opportunity
294 try:
295 await _core.wait_task_rescheduled(lambda _: _core.Abort.SUCCEEDED)
296 except _core.Cancelled:
297 record.add(name + " cancel ok")
298
299 # simulated control-C during raiser, which is *unprotected*
300 print("check 1")

Callers 1

get_excFunction · 0.70

Calls 2

ki_selfFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…