MCPcopy Create free account
hub / github.com/alibaba/GraphScope / CaptureKeyboardInterrupt

Class CaptureKeyboardInterrupt

python/graphscope/client/utils.py:297–322  ·  view source on GitHub ↗

Context Manager for capture keyboard interrupt Args: callback: function Callback function when KeyboardInterrupt occurs. Examples: >>> with CaptureKeyboardInterrupt(callback): >>> do_somethings()

Source from the content-addressed store, hash-verified

295
296
297class CaptureKeyboardInterrupt(object):
298 """Context Manager for capture keyboard interrupt
299
300 Args:
301 callback: function
302 Callback function when KeyboardInterrupt occurs.
303
304 Examples:
305 >>> with CaptureKeyboardInterrupt(callback):
306 >>> do_somethings()
307 """
308
309 def __init__(self, callback=None):
310 self._callback = callback
311
312 def __enter__(self):
313 return self
314
315 def __exit__(self, exc_type, exc_value, exc_tb):
316 if exc_type is not None:
317 if self._callback:
318 try:
319 self._callback()
320 except: # noqa: E722
321 pass
322 return False
323
324
325class SignalIgnore(object):

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected