MCPcopy Create free account
hub / github.com/python-cmd2/cmd2 / __init__

Method __init__

examples/async_printing.py:33–47  ·  view source on GitHub ↗

Initializer.

(self)

Source from the content-addressed store, hash-verified

31 """An app that shows off async_alert() and async_update_prompt()."""
32
33 def __init__(self) -> None:
34 """Initializer."""
35 super().__init__()
36
37 self.prompt = "(APR)> "
38
39 # The thread that will asynchronously alert the user of events
40 self._stop_event = threading.Event()
41 self._add_alert_thread = threading.Thread()
42 self._alert_count = 0
43 self._next_alert_time = 0.0
44
45 # Create some hooks to handle the starting and stopping of our thread
46 self.register_preloop_hook(self._preloop_hook)
47 self.register_postloop_hook(self._postloop_hook)
48
49 def _preloop_hook(self) -> None:
50 """Start the alerter thread."""

Callers

nothing calls this directly

Calls 2

register_preloop_hookMethod · 0.80

Tested by

no test coverage detected