diff options
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/async_printing.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/async_printing.py b/examples/async_printing.py index 23147865..feda24c0 100755 --- a/examples/async_printing.py +++ b/examples/async_printing.py @@ -45,7 +45,7 @@ class AlerterApp(cmd2.Cmd): def _preloop_hook(self) -> None: """ Start the alerter thread """ - # This runs after cmdloop() acquires self._terminal_lock, which will be locked until the prompt appears. + # This runs after cmdloop() acquires self.terminal_lock, which will be locked until the prompt appears. # Therefore this is the best place to start the alerter thread since there is no risk of it alerting # before the prompt is displayed. You can also start it via a command if its not something that should # be running during the entire application. See do_start_alerts(). @@ -57,7 +57,7 @@ class AlerterApp(cmd2.Cmd): def _postloop_hook(self) -> None: """ Stops the alerter thread """ - # After this function returns, cmdloop() releases self._terminal_lock which could make the alerter + # After this function returns, cmdloop() releases self.terminal_lock which could make the alerter # thread think the prompt is on screen. Therefore this is the best place to stop the alerter thread. # You can also stop it via a command. See do_stop_alerts(). self._stop_thread = True @@ -166,9 +166,9 @@ class AlerterApp(cmd2.Cmd): self._next_alert_time = 0 while not self._stop_thread: - # Always acquire _terminal_lock before printing alerts or updating the prompt + # Always acquire terminal_lock before printing alerts or updating the prompt # To keep the app responsive, do not block on this call - if self._terminal_lock.acquire(blocking=False): + if self.terminal_lock.acquire(blocking=False): # Get any alerts that need to be printed alert_str = self._generate_alert_str() @@ -178,15 +178,15 @@ class AlerterApp(cmd2.Cmd): # Check if we have alerts to print if alert_str: - # new_prompt is an optional parameter to _async_alert() - self._async_alert(alert_str, new_prompt) + # new_prompt is an optional parameter to async_alert() + self.async_alert(alert_str, new_prompt) # No alerts needed to be printed, check if the prompt changed elif new_prompt != self.prompt: - self._async_update_prompt(new_prompt) + self.async_update_prompt(new_prompt) # Don't forget to release the lock - self._terminal_lock.release() + self.terminal_lock.release() time.sleep(0.5) |