Merge pull request #1514 from mwhudson/remove-aio_loop

Remove Application.aio_loop attribute
This commit is contained in:
Michael Hudson-Doyle 2022-12-09 10:53:50 +13:00 committed by GitHub
commit 6e1c42c385
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 10 deletions

View File

@ -289,7 +289,7 @@ class InstallRunning(Stretchy):
self.btn = Toggleable(other_btn(
_("Switch to a shell"), on_press=self._debug_shell))
self.btn.enabled = False
self.app.aio_loop.call_later(0.5, self._enable)
self._enable_task = asyncio.create_task(self._enable())
widgets = [
Text(rewrap(_(running_text).format(tty=tty))),
Text(''),
@ -301,7 +301,8 @@ class InstallRunning(Stretchy):
stretchy_index=0,
focus_index=2)
def _enable(self):
async def _enable(self):
await asyncio.sleep(0.5)
self.btn.enabled = True
def _debug_shell(self, sender):

View File

@ -228,7 +228,9 @@ class RefreshView(BaseView):
if self.controller.answers['update']:
self.update()
else:
self.controller.app.aio_loop.call_soon(self.skip_update)
async def skip():
self.skip_update()
self._skip_task = asyncio.create_task(skip())
def update(self, sender=None):
self.spinner.stop()

View File

@ -13,7 +13,6 @@ class IdentityViewTests(unittest.TestCase):
def make_view(self):
controller = mock.create_autospec(spec=ProgressController)
controller.app = mock.Mock()
controller.app.aio_loop = None
return ProgressView(controller)
def test_initial_focus(self):

View File

@ -70,8 +70,8 @@ class Application:
os.environ.get('SUBIQUITY_REPLAY_TIMESCALE', "1"))
self.updated = os.path.exists(self.state_path('updating'))
self.hub = MessageHub()
self.aio_loop = asyncio.get_running_loop()
self.aio_loop.set_exception_handler(self._exception_handler)
asyncio.get_running_loop().set_exception_handler(
self._exception_handler)
self.load_controllers(self.controllers)
self.context = Context.new(self)
self.exit_event = asyncio.Event()

View File

@ -154,7 +154,8 @@ class TuiApplication(Application):
"""
min_show_task = None
def _show():
async def _show():
await asyncio.sleep(MAX_BLOCK_TIME)
self.ui.block_input = False
nonlocal min_show_task
min_show_task = asyncio.create_task(
@ -162,7 +163,7 @@ class TuiApplication(Application):
show()
self.ui.block_input = True
show_handle = self.aio_loop.call_later(MAX_BLOCK_TIME, _show)
show_task = asyncio.create_task(_show())
try:
result = await awaitable
finally:
@ -172,7 +173,7 @@ class TuiApplication(Application):
hide()
else:
self.ui.block_input = False
show_handle.cancel()
show_task.cancel()
return result
@ -296,7 +297,7 @@ class TuiApplication(Application):
self.ui, screen=screen,
handle_mouse=False, pop_ups=True,
unhandled_input=self.unhandled_input,
event_loop=urwid.AsyncioEventLoop(loop=self.aio_loop),
event_loop=urwid.AsyncioEventLoop(loop=asyncio.get_running_loop()),
**self.extra_urwid_loop_args()
)
extend_dec_special_charmap()