Skip to content

Commit c8aac52

Browse files
committed
Allow to disable concurrency check for all UIScreen inputs
Right now it is possible to disable concurrency check for InputHandler. However, this class is created on demand in the InputManager used by the UIScreen which means that a users are not able to disable concurrency_check without re-implementation of the InputManager and InputHandler which is really cumbersome. To solve this I'm adding a new property to InputManager and enable obtaining the InputManager instance from the UIScreen. The concurrency check shouldn't be disabled if you don't have a strong reason to do it. It was implemented because without the check it's really hard to debug when multiple screens are asking for the input at once. The main reason to disable it is for error reporting after the application has crashed. Resolves: rhbz#2134888 (cherry picked from commit e3ecece)
1 parent 0bbf959 commit c8aac52

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

simpleline/render/screen/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ def title(self, title):
8787
"""
8888
self._title = title
8989

90+
@property
91+
def input_manager(self):
92+
"""Get input manager.
93+
94+
The input manager could be used to tweak input settings.
95+
"""
96+
return self._input_manager
97+
9098
@property
9199
def password_func(self):
92100
"""Get password function.

simpleline/render/screen/input_manager.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self, ui_screen):
4646
self._ui_screen = ui_screen
4747
self._input_error_counter = 0
4848
self._input_error_threshold = 5
49+
self._skip_concurrency_check = False
4950
self._input_args = None
5051

5152
@property
@@ -62,6 +63,25 @@ def input_error_threshold_exceeded(self):
6263
errors = self._input_error_counter % self._input_error_threshold
6364
return errors == 0
6465

66+
@property
67+
def skip_concurrency_check(self):
68+
"""Should the concurrency check be skipped?
69+
70+
:returns bool: True if the check should be skipped.
71+
"""
72+
return self._skip_concurrency_check
73+
74+
@skip_concurrency_check.setter
75+
def skip_concurrency_check(self, value):
76+
"""Set if the concurrency check should be skipped when asking for user input.
77+
78+
WARNING: Use this option with caution. When the concurrency check is disabled you
79+
can easily get to unexpected behavior which is hard to debug.
80+
81+
:param bool value: True to skip the concurrency check.
82+
"""
83+
self._skip_concurrency_check = value
84+
6585
def get_input_blocking(self, message, hidden):
6686
"""Get blocking input from the user.
6787
@@ -78,6 +98,7 @@ def get_input_blocking(self, message, hidden):
7898
else:
7999
handler = InputHandler(source=self)
80100

101+
handler.skip_concurrency_check = self._skip_concurrency_check
81102
handler.get_input(message)
82103
handler.wait_on_input()
83104
return handler.value
@@ -101,6 +122,7 @@ def get_input(self, args=None):
101122
if self._ui_screen.password_func:
102123
handler.set_pass_func(self._ui_screen.password_func)
103124

125+
handler.skip_concurrency_check = self._skip_concurrency_check
104126
handler.set_callback(self.process_input)
105127
handler.get_input(prompt)
106128

0 commit comments

Comments
 (0)