@@ -530,7 +530,7 @@ def __init__(self, completekey: str='tab', stdin=None, stdout=None, persistent_h
530530 # This lock should be acquired before doing any asynchronous changes to the terminal to
531531 # ensure the updates to the terminal don't interfere with the input being typed. It can be
532532 # acquired any time there is a readline prompt on screen.
533- self ._terminal_lock = threading .RLock ()
533+ self .terminal_lock = threading .RLock ()
534534
535535 # ----- Methods related to presenting output to the user -----
536536
@@ -2085,10 +2085,10 @@ def pseudo_raw_input(self, prompt: str) -> str:
20852085 if self .use_rawinput :
20862086 try :
20872087 if sys .stdin .isatty ():
2088- # Wrap in try since _terminal_lock may not be locked when this function is called from unit tests
2088+ # Wrap in try since terminal_lock may not be locked when this function is called from unit tests
20892089 try :
20902090 # A prompt is about to be drawn. Allow asynchronous changes to the terminal.
2091- self ._terminal_lock .release ()
2091+ self .terminal_lock .release ()
20922092 except RuntimeError :
20932093 pass
20942094
@@ -2104,7 +2104,7 @@ def pseudo_raw_input(self, prompt: str) -> str:
21042104 finally :
21052105 if sys .stdin .isatty ():
21062106 # The prompt is gone. Do not allow asynchronous changes to the terminal.
2107- self ._terminal_lock .acquire ()
2107+ self .terminal_lock .acquire ()
21082108 else :
21092109 if self .stdin .isatty ():
21102110 # on a tty, print the prompt first, then read the line
@@ -3237,25 +3237,25 @@ def _clear_input_lines_str(self) -> str:
32373237
32383238 return terminal_str
32393239
3240- def _async_alert (self , alert_msg : str , new_prompt : Optional [str ] = None ) -> None :
3240+ def async_alert (self , alert_msg : str , new_prompt : Optional [str ] = None ) -> None :
32413241 """
32423242 Used to display an important message to the user while they are at the prompt in between commands.
32433243 To the user it appears as if an alert message is printed above the prompt and their current input
32443244 text and cursor location is left alone.
32453245
3246- IMPORTANT: Do not call this unless you have acquired self._terminal_lock
3246+ IMPORTANT: Do not call this unless you have acquired self.terminal_lock
32473247 first, which ensures a prompt is onscreen
32483248
32493249 :param alert_msg: the message to display to the user
32503250 :param new_prompt: if you also want to change the prompt that is displayed, then include it here
32513251 see async_update_prompt() docstring for guidance on updating a prompt
3252- :raises RuntimeError if called while another thread holds _terminal_lock
3252+ :raises RuntimeError if called while another thread holds terminal_lock
32533253 """
32543254 if not (vt100_support and self .use_rawinput ):
32553255 return
32563256
3257- # Sanity check that can't fail if self._terminal_lock was acquired before calling this function
3258- if self ._terminal_lock .acquire (blocking = False ):
3257+ # Sanity check that can't fail if self.terminal_lock was acquired before calling this function
3258+ if self .terminal_lock .acquire (blocking = False ):
32593259
32603260 # Generate a string to clear the prompt and input lines and replace with the alert
32613261 terminal_str = self ._clear_input_lines_str ()
@@ -3275,30 +3275,30 @@ def _async_alert(self, alert_msg: str, new_prompt: Optional[str] = None) -> None
32753275 # Redraw the prompt and input lines
32763276 rl_force_redisplay ()
32773277
3278- self ._terminal_lock .release ()
3278+ self .terminal_lock .release ()
32793279
32803280 else :
3281- raise RuntimeError ("another thread holds _terminal_lock " )
3281+ raise RuntimeError ("another thread holds terminal_lock " )
32823282
3283- def _async_update_prompt (self , new_prompt : str ) -> None :
3283+ def async_update_prompt (self , new_prompt : str ) -> None :
32843284 """
32853285 Updates the prompt while the user is still typing at it. This is good for alerting the user to system
32863286 changes dynamically in between commands. For instance you could alter the color of the prompt to indicate
32873287 a system status or increase a counter to report an event. If you do alter the actual text of the prompt,
32883288 it is best to keep the prompt the same width as what's on screen. Otherwise the user's input text will
32893289 be shifted and the update will not be seamless.
32903290
3291- IMPORTANT: Do not call this unless you have acquired self._terminal_lock
3291+ IMPORTANT: Do not call this unless you have acquired self.terminal_lock
32923292 first, which ensures a prompt is onscreen
32933293
32943294 :param new_prompt: what to change the prompt to
3295- :raises RuntimeError if called while another thread holds _terminal_lock
3295+ :raises RuntimeError if called while another thread holds terminal_lock
32963296 """
32973297 if not (vt100_support and self .use_rawinput ):
32983298 return
32993299
3300- # Sanity check that can't fail if self._terminal_lock was acquired before calling this function
3301- if self ._terminal_lock .acquire (blocking = False ):
3300+ # Sanity check that can't fail if self.terminal_lock was acquired before calling this function
3301+ if self .terminal_lock .acquire (blocking = False ):
33023302
33033303 # Generate a string to clear the prompt and input lines
33043304 terminal_str = self ._clear_input_lines_str ()
@@ -3316,10 +3316,10 @@ def _async_update_prompt(self, new_prompt: str) -> None:
33163316 # Redraw the prompt and input lines
33173317 rl_force_redisplay ()
33183318
3319- self ._terminal_lock .release ()
3319+ self .terminal_lock .release ()
33203320
33213321 else :
3322- raise RuntimeError ("another thread holds _terminal_lock " )
3322+ raise RuntimeError ("another thread holds terminal_lock " )
33233323
33243324 @staticmethod
33253325 def set_window_title (title : str ) -> None :
@@ -3368,7 +3368,7 @@ def cmdloop(self, intro: Optional[str]=None) -> None:
33683368 signal .signal (signal .SIGINT , self .sigint_handler )
33693369
33703370 # Grab terminal lock before the prompt has been drawn by readline
3371- self ._terminal_lock .acquire ()
3371+ self .terminal_lock .acquire ()
33723372
33733373 # Always run the preloop first
33743374 for func in self ._preloop_hooks :
@@ -3397,7 +3397,7 @@ def cmdloop(self, intro: Optional[str]=None) -> None:
33973397
33983398 # Release terminal lock now that postloop code should have stopped any terminal updater threads
33993399 # This will also zero the lock count in case cmdloop() is called again
3400- self ._terminal_lock .release ()
3400+ self .terminal_lock .release ()
34013401
34023402 # Restore the original signal handler
34033403 signal .signal (signal .SIGINT , original_sigint_handler )
0 commit comments