many: s/create_task/run_bg_task/
create_task has the following note: Important: Save a reference to the result of this function, to avoid a task disappearing mid-execution. Convert existing usage of create_task to run_bg_task, if that create_task is not actually storing the result.
This commit is contained in:
parent
ffa29c4fcb
commit
9d12871f15
|
@ -26,6 +26,7 @@ from typing import Callable, Dict, List, Optional, Union
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from subiquitycore.async_helpers import (
|
from subiquitycore.async_helpers import (
|
||||||
|
run_bg_task,
|
||||||
run_in_thread,
|
run_in_thread,
|
||||||
)
|
)
|
||||||
from subiquitycore.screen import is_linux_tty
|
from subiquitycore.screen import is_linux_tty
|
||||||
|
@ -172,7 +173,7 @@ class SubiquityClient(TuiApplication):
|
||||||
"killing foreground process %s before restarting",
|
"killing foreground process %s before restarting",
|
||||||
self.fg_proc)
|
self.fg_proc)
|
||||||
self.restarting = True
|
self.restarting = True
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self._kill_fg_proc(remove_last_screen, restart_server))
|
self._kill_fg_proc(remove_last_screen, restart_server))
|
||||||
return
|
return
|
||||||
if remove_last_screen:
|
if remove_last_screen:
|
||||||
|
@ -180,7 +181,7 @@ class SubiquityClient(TuiApplication):
|
||||||
if restart_server:
|
if restart_server:
|
||||||
self.restarting = True
|
self.restarting = True
|
||||||
self.ui.block_input = True
|
self.ui.block_input = True
|
||||||
asyncio.create_task(self._restart_server())
|
run_bg_task(self._restart_server())
|
||||||
return
|
return
|
||||||
if self.urwid_loop is not None:
|
if self.urwid_loop is not None:
|
||||||
self.urwid_loop.stop()
|
self.urwid_loop.stop()
|
||||||
|
@ -380,7 +381,7 @@ class SubiquityClient(TuiApplication):
|
||||||
[status.event_syslog_id],
|
[status.event_syslog_id],
|
||||||
self.subiquity_event_noninteractive,
|
self.subiquity_event_noninteractive,
|
||||||
seek=True)
|
seek=True)
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.noninteractive_watch_app_state(status))
|
self.noninteractive_watch_app_state(status))
|
||||||
|
|
||||||
def _exception_handler(self, loop, context):
|
def _exception_handler(self, loop, context):
|
||||||
|
@ -494,7 +495,7 @@ class SubiquityClient(TuiApplication):
|
||||||
for i, controller in enumerate(self.controllers.instances):
|
for i, controller in enumerate(self.controllers.instances):
|
||||||
if controller.name == last_screen:
|
if controller.name == last_screen:
|
||||||
index = i
|
index = i
|
||||||
asyncio.create_task(self._select_initial_screen(index))
|
run_bg_task(self._select_initial_screen(index))
|
||||||
|
|
||||||
async def _select_initial_screen(self, index):
|
async def _select_initial_screen(self, index):
|
||||||
endpoint_names = []
|
endpoint_names = []
|
||||||
|
@ -544,7 +545,7 @@ class SubiquityClient(TuiApplication):
|
||||||
finally:
|
finally:
|
||||||
self.in_make_view_cvar.reset(tok)
|
self.in_make_view_cvar.reset(tok)
|
||||||
if new.answers:
|
if new.answers:
|
||||||
asyncio.create_task(self._start_answers_for_view(new, view))
|
run_bg_task(self._start_answers_for_view(new, view))
|
||||||
with open(self.state_path('last-screen'), 'w') as fp:
|
with open(self.state_path('last-screen'), 'w') as fp:
|
||||||
fp.write(new.name)
|
fp.write(new.name)
|
||||||
return view
|
return view
|
||||||
|
@ -575,7 +576,7 @@ class SubiquityClient(TuiApplication):
|
||||||
elif key == 'ctrl u':
|
elif key == 'ctrl u':
|
||||||
1/0
|
1/0
|
||||||
elif key == 'ctrl b':
|
elif key == 'ctrl b':
|
||||||
asyncio.create_task(self.client.dry_run.crash.GET())
|
run_bg_task(self.client.dry_run.crash.GET())
|
||||||
else:
|
else:
|
||||||
super().unhandled_input(key)
|
super().unhandled_input(key)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.lsb_release import lsb_release
|
from subiquitycore.lsb_release import lsb_release
|
||||||
from subiquitycore.view import BaseView
|
from subiquitycore.view import BaseView
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator):
|
||||||
|
|
||||||
status = await self.endpoint.guided.GET()
|
status = await self.endpoint.guided.GET()
|
||||||
if status.status == ProbeStatus.PROBING:
|
if status.status == ProbeStatus.PROBING:
|
||||||
asyncio.create_task(self._wait_for_probing())
|
run_bg_task(self._wait_for_probing())
|
||||||
self.current_view = SlowProbing(self)
|
self.current_view = SlowProbing(self)
|
||||||
else:
|
else:
|
||||||
self.current_view = self.make_guided_ui(status)
|
self.current_view = self.make_guided_ui(status)
|
||||||
|
@ -273,18 +274,18 @@ class FilesystemController(SubiquityTuiController, FilesystemManipulator):
|
||||||
self.ui.set_body(FilesystemView(self.model, self))
|
self.ui.set_body(FilesystemView(self.model, self))
|
||||||
|
|
||||||
def guided_choice(self, choice):
|
def guided_choice(self, choice):
|
||||||
asyncio.create_task(self._guided_choice(choice))
|
run_bg_task(self._guided_choice(choice))
|
||||||
|
|
||||||
async def _guided(self):
|
async def _guided(self):
|
||||||
self.ui.set_body((await self.make_ui())())
|
self.ui.set_body((await self.make_ui())())
|
||||||
|
|
||||||
def guided(self):
|
def guided(self):
|
||||||
asyncio.create_task(self._guided())
|
run_bg_task(self._guided())
|
||||||
|
|
||||||
def reset(self, refresh_view):
|
def reset(self, refresh_view):
|
||||||
log.info("Resetting Filesystem model")
|
log.info("Resetting Filesystem model")
|
||||||
self.app.ui.block_input = True
|
self.app.ui.block_input = True
|
||||||
asyncio.create_task(self._reset(refresh_view))
|
run_bg_task(self._reset(refresh_view))
|
||||||
|
|
||||||
async def _reset(self, refresh_view):
|
async def _reset(self, refresh_view):
|
||||||
status = await self.endpoint.reset.POST()
|
status = await self.endpoint.reset.POST()
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -22,6 +21,7 @@ from typing import List, Optional
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.controllers.network import NetworkAnswersMixin
|
from subiquitycore.controllers.network import NetworkAnswersMixin
|
||||||
from subiquitycore.models.network import (
|
from subiquitycore.models.network import (
|
||||||
BondConfig,
|
BondConfig,
|
||||||
|
@ -118,7 +118,7 @@ class NetworkController(SubiquityTuiController, NetworkAnswersMixin):
|
||||||
def end_ui(self):
|
def end_ui(self):
|
||||||
if self.view is not None:
|
if self.view is not None:
|
||||||
self.view = None
|
self.view = None
|
||||||
asyncio.create_task(self.unsubscribe())
|
run_bg_task(self.unsubscribe())
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
self.app.prev_screen()
|
self.app.prev_screen()
|
||||||
|
@ -128,36 +128,36 @@ class NetworkController(SubiquityTuiController, NetworkAnswersMixin):
|
||||||
|
|
||||||
def set_static_config(self, dev_name: str, ip_version: int,
|
def set_static_config(self, dev_name: str, ip_version: int,
|
||||||
static_config: StaticConfig) -> None:
|
static_config: StaticConfig) -> None:
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.set_static_config.POST(
|
self.endpoint.set_static_config.POST(
|
||||||
dev_name, ip_version, static_config))
|
dev_name, ip_version, static_config))
|
||||||
|
|
||||||
def enable_dhcp(self, dev_name, ip_version: int) -> None:
|
def enable_dhcp(self, dev_name, ip_version: int) -> None:
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.enable_dhcp.POST(dev_name, ip_version))
|
self.endpoint.enable_dhcp.POST(dev_name, ip_version))
|
||||||
|
|
||||||
def disable_network(self, dev_name: str, ip_version: int) -> None:
|
def disable_network(self, dev_name: str, ip_version: int) -> None:
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.disable.POST(dev_name, ip_version))
|
self.endpoint.disable.POST(dev_name, ip_version))
|
||||||
|
|
||||||
def add_vlan(self, dev_name: str, vlan_id: int):
|
def add_vlan(self, dev_name: str, vlan_id: int):
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.vlan.PUT(dev_name, vlan_id))
|
self.endpoint.vlan.PUT(dev_name, vlan_id))
|
||||||
|
|
||||||
def set_wlan(self, dev_name: str, wlan: WLANConfig) -> None:
|
def set_wlan(self, dev_name: str, wlan: WLANConfig) -> None:
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.set_wlan.POST(dev_name, wlan))
|
self.endpoint.set_wlan.POST(dev_name, wlan))
|
||||||
|
|
||||||
def start_scan(self, dev_name: str) -> None:
|
def start_scan(self, dev_name: str) -> None:
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.start_scan.POST(dev_name))
|
self.endpoint.start_scan.POST(dev_name))
|
||||||
|
|
||||||
def delete_link(self, dev_name: str):
|
def delete_link(self, dev_name: str):
|
||||||
asyncio.create_task(self.endpoint.delete.POST(dev_name))
|
run_bg_task(self.endpoint.delete.POST(dev_name))
|
||||||
|
|
||||||
def add_or_update_bond(self, existing_name: Optional[str],
|
def add_or_update_bond(self, existing_name: Optional[str],
|
||||||
new_name: str, new_info: BondConfig) -> None:
|
new_name: str, new_info: BondConfig) -> None:
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self.endpoint.add_or_edit_bond.POST(
|
self.endpoint.add_or_edit_bond.POST(
|
||||||
existing_name, new_name, new_info))
|
existing_name, new_name, new_info))
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import logging
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
|
|
||||||
from subiquity.client.controller import SubiquityTuiController
|
from subiquity.client.controller import SubiquityTuiController
|
||||||
|
@ -61,10 +62,10 @@ class ProgressController(SubiquityTuiController):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
asyncio.create_task(self._wait_status())
|
run_bg_task(self._wait_status())
|
||||||
|
|
||||||
def click_reboot(self):
|
def click_reboot(self):
|
||||||
asyncio.create_task(self.send_reboot_and_wait())
|
run_bg_task(self.send_reboot_and_wait())
|
||||||
|
|
||||||
async def send_reboot_and_wait(self):
|
async def send_reboot_and_wait(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -21,6 +21,7 @@ from typing import List, Sequence, Union
|
||||||
import attr
|
import attr
|
||||||
from systemd import journal
|
from systemd import journal
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.utils import arun_command
|
from subiquitycore.utils import arun_command
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ class LateController(CmdListController):
|
||||||
return env
|
return env
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
asyncio.create_task(self._run())
|
run_bg_task(self._run())
|
||||||
|
|
||||||
async def _run(self):
|
async def _run(self):
|
||||||
Install = self.app.controllers.Install
|
Install = self.app.controllers.Install
|
||||||
|
|
|
@ -28,6 +28,7 @@ import attr
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from subiquitycore.async_helpers import (
|
from subiquitycore.async_helpers import (
|
||||||
|
run_bg_task,
|
||||||
run_in_thread,
|
run_in_thread,
|
||||||
)
|
)
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
|
@ -142,7 +143,7 @@ class InstallController(SubiquityController):
|
||||||
def stop_uu(self):
|
def stop_uu(self):
|
||||||
if self.app.state == ApplicationState.UU_RUNNING:
|
if self.app.state == ApplicationState.UU_RUNNING:
|
||||||
self.app.update_state(ApplicationState.UU_CANCELLING)
|
self.app.update_state(ApplicationState.UU_CANCELLING)
|
||||||
asyncio.create_task(self.stop_unattended_upgrades())
|
run_bg_task(self.stop_unattended_upgrades())
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
journald_listen([self.app.log_syslog_id], self.log_event)
|
journald_listen([self.app.log_syslog_id], self.log_event)
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ class LocaleController(SubiquityController):
|
||||||
self.model.selected_language = os.environ.get("LANG") \
|
self.model.selected_language = os.environ.get("LANG") \
|
||||||
or self.autoinstall_default
|
or self.autoinstall_default
|
||||||
|
|
||||||
asyncio.create_task(self.configured())
|
async_helpers.run_bg_task(self.configured())
|
||||||
self.app.hub.subscribe(
|
self.app.hub.subscribe(
|
||||||
(InstallerChannels.CONFIGURED, 'source'), self._set_source)
|
(InstallerChannels.CONFIGURED, 'source'), self._set_source)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,10 @@ import aiohttp
|
||||||
|
|
||||||
import apt
|
import apt
|
||||||
|
|
||||||
from subiquitycore.async_helpers import schedule_task
|
from subiquitycore.async_helpers import (
|
||||||
|
run_bg_task,
|
||||||
|
schedule_task,
|
||||||
|
)
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.controllers.network import BaseNetworkController
|
from subiquitycore.controllers.network import BaseNetworkController
|
||||||
from subiquitycore.models.network import (
|
from subiquitycore.models.network import (
|
||||||
|
@ -302,7 +305,7 @@ class NetworkController(BaseNetworkController, SubiquityController):
|
||||||
client = make_client_for_conn(NetEventAPI, conn)
|
client = make_client_for_conn(NetEventAPI, conn)
|
||||||
lock = asyncio.Lock()
|
lock = asyncio.Lock()
|
||||||
self.clients[socket_path] = (client, conn, lock)
|
self.clients[socket_path] = (client, conn, lock)
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self._call_client(
|
self._call_client(
|
||||||
client, conn, lock, "route_watch",
|
client, conn, lock, "route_watch",
|
||||||
self.network_event_receiver.default_routes))
|
self.network_event_receiver.default_routes))
|
||||||
|
@ -329,7 +332,7 @@ class NetworkController(BaseNetworkController, SubiquityController):
|
||||||
def _call_clients(self, meth_name, *args):
|
def _call_clients(self, meth_name, *args):
|
||||||
for client, conn, lock in self.clients.values():
|
for client, conn, lock in self.clients.values():
|
||||||
log.debug('creating _call_client task %s %s', conn.path, meth_name)
|
log.debug('creating _call_client task %s %s', conn.path, meth_name)
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self._call_client(client, conn, lock, meth_name, *args))
|
self._call_client(client, conn, lock, meth_name, *args))
|
||||||
|
|
||||||
def apply_starting(self):
|
def apply_starting(self):
|
||||||
|
|
|
@ -23,6 +23,7 @@ from subiquitycore.file_util import (
|
||||||
open_perms,
|
open_perms,
|
||||||
set_log_perms,
|
set_log_perms,
|
||||||
)
|
)
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.utils import arun_command, run_command
|
from subiquitycore.utils import arun_command, run_command
|
||||||
|
|
||||||
|
@ -73,8 +74,8 @@ class ShutdownController(SubiquityController):
|
||||||
return self.app.interactive
|
return self.app.interactive
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
asyncio.create_task(self._wait_install())
|
run_bg_task(self._wait_install())
|
||||||
asyncio.create_task(self._run())
|
run_bg_task(self._run())
|
||||||
|
|
||||||
async def _wait_install(self):
|
async def _wait_install(self):
|
||||||
await self.app.controllers.Install.install_task
|
await self.app.controllers.Install.install_task
|
||||||
|
|
|
@ -89,8 +89,7 @@ class SnapdSnapInfoLoader:
|
||||||
|
|
||||||
async def _start(self):
|
async def _start(self):
|
||||||
with self.context:
|
with self.context:
|
||||||
task = self.tasks[None] = \
|
task = self.tasks[None] = asyncio.create_task(self._load_list())
|
||||||
asyncio.create_task(self._load_list())
|
|
||||||
self.load_list_task_created.set()
|
self.load_list_task_created.set()
|
||||||
try:
|
try:
|
||||||
await task
|
await task
|
||||||
|
|
|
@ -32,7 +32,10 @@ from systemd import journal
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from subiquitycore.async_helpers import run_in_thread
|
from subiquitycore.async_helpers import (
|
||||||
|
run_bg_task,
|
||||||
|
run_in_thread,
|
||||||
|
)
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.core import Application
|
from subiquitycore.core import Application
|
||||||
from subiquitycore.file_util import (
|
from subiquitycore.file_util import (
|
||||||
|
@ -426,7 +429,7 @@ class SubiquityServer(Application):
|
||||||
self.update_state(ApplicationState.ERROR)
|
self.update_state(ApplicationState.ERROR)
|
||||||
if not self.running_error_commands:
|
if not self.running_error_commands:
|
||||||
self.running_error_commands = True
|
self.running_error_commands = True
|
||||||
asyncio.create_task(self._run_error_cmds(report))
|
run_bg_task(self._run_error_cmds(report))
|
||||||
|
|
||||||
@web.middleware
|
@web.middleware
|
||||||
async def middleware(self, request, handler):
|
async def middleware(self, request, handler):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
""" Module defining the view for third-party drivers installation.
|
""" Module defining the view for third-party drivers installation.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
from enum import auto, Enum
|
from enum import auto, Enum
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
@ -26,6 +25,7 @@ from urwid import (
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.ui.buttons import back_btn, ok_btn
|
from subiquitycore.ui.buttons import back_btn, ok_btn
|
||||||
from subiquitycore.ui.form import (
|
from subiquitycore.ui.form import (
|
||||||
Form,
|
Form,
|
||||||
|
@ -111,7 +111,7 @@ class DriversView(BaseView):
|
||||||
_("Back"),
|
_("Back"),
|
||||||
on_press=lambda sender: self.cancel())
|
on_press=lambda sender: self.cancel())
|
||||||
self._w = screen(rows, [self.back_btn])
|
self._w = screen(rows, [self.back_btn])
|
||||||
asyncio.create_task(self._wait(install))
|
run_bg_task(self._wait(install))
|
||||||
self.status = DriversViewStatus.WAITING
|
self.status = DriversViewStatus.WAITING
|
||||||
|
|
||||||
async def _wait(self, install: bool) -> None:
|
async def _wait(self, install: bool) -> None:
|
||||||
|
|
|
@ -24,6 +24,7 @@ from urwid import (
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.ui.buttons import other_btn
|
from subiquitycore.ui.buttons import other_btn
|
||||||
from subiquitycore.ui.container import (
|
from subiquitycore.ui.container import (
|
||||||
Pile,
|
Pile,
|
||||||
|
@ -153,7 +154,7 @@ class ErrorReportStretchy(Stretchy):
|
||||||
self.report = app.error_reporter.get(ref)
|
self.report = app.error_reporter.get(ref)
|
||||||
self.pending = None
|
self.pending = None
|
||||||
if self.report is None:
|
if self.report is None:
|
||||||
asyncio.create_task(self._wait())
|
run_bg_task(self._wait())
|
||||||
else:
|
else:
|
||||||
connect_signal(self.report, 'changed', self._report_changed)
|
connect_signal(self.report, 'changed', self._report_changed)
|
||||||
self.report.mark_seen()
|
self.report.mark_seen()
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -25,6 +24,7 @@ from urwid import (
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.lsb_release import lsb_release
|
from subiquitycore.lsb_release import lsb_release
|
||||||
from subiquitycore.ssh import summarize_host_keys
|
from subiquitycore.ssh import summarize_host_keys
|
||||||
from subiquitycore.ui.buttons import (
|
from subiquitycore.ui.buttons import (
|
||||||
|
@ -410,7 +410,7 @@ class HelpMenu(PopUpLauncher):
|
||||||
|
|
||||||
def _open(self, sender):
|
def _open(self, sender):
|
||||||
log.debug("open help menu")
|
log.debug("open help menu")
|
||||||
asyncio.create_task(self._get_ssh_info())
|
run_bg_task(self._get_ssh_info())
|
||||||
|
|
||||||
def create_pop_up(self):
|
def create_pop_up(self):
|
||||||
self._menu = OpenHelpMenu(self)
|
self._menu = OpenHelpMenu(self)
|
||||||
|
|
|
@ -21,6 +21,7 @@ from urwid import (
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.view import BaseView
|
from subiquitycore.view import BaseView
|
||||||
from subiquitycore.ui.buttons import (
|
from subiquitycore.ui.buttons import (
|
||||||
cancel_btn,
|
cancel_btn,
|
||||||
|
@ -266,7 +267,7 @@ class InstallConfirmation(Stretchy):
|
||||||
self.app.ui.body.hide_continue()
|
self.app.ui.body.hide_continue()
|
||||||
self.app.remove_global_overlay(self)
|
self.app.remove_global_overlay(self)
|
||||||
if self.app.controllers.Progress.showing:
|
if self.app.controllers.Progress.showing:
|
||||||
asyncio.create_task(self.app.confirm_install())
|
run_bg_task(self.app.confirm_install())
|
||||||
else:
|
else:
|
||||||
self.app.next_screen(self.app.confirm_install())
|
self.app.next_screen(self.app.confirm_install())
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import locale
|
import locale
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ from urwid import (
|
||||||
Padding as UrwidPadding
|
Padding as UrwidPadding
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.ui.buttons import (
|
from subiquitycore.ui.buttons import (
|
||||||
cancel_btn,
|
cancel_btn,
|
||||||
ok_btn,
|
ok_btn,
|
||||||
|
@ -259,8 +259,7 @@ class Detector:
|
||||||
|
|
||||||
def do_step(self, step_index):
|
def do_step(self, step_index):
|
||||||
self.abort()
|
self.abort()
|
||||||
asyncio.create_task(
|
run_bg_task(self._do_step(step_index))
|
||||||
self._do_step(step_index))
|
|
||||||
|
|
||||||
async def _do_step(self, step_index):
|
async def _do_step(self, step_index):
|
||||||
log.debug("moving to step %s", step_index)
|
log.debug("moving to step %s", step_index)
|
||||||
|
@ -423,7 +422,7 @@ class KeyboardView(BaseView):
|
||||||
layout = data['layout']
|
layout = data['layout']
|
||||||
variant = data.get('variant', layout.variants[0])
|
variant = data.get('variant', layout.variants[0])
|
||||||
setting = KeyboardSetting(layout=layout.code, variant=variant.code)
|
setting = KeyboardSetting(layout=layout.code, variant=variant.code)
|
||||||
asyncio.create_task(self._check_toggle(setting))
|
run_bg_task(self._check_toggle(setting))
|
||||||
|
|
||||||
async def _apply(self, setting):
|
async def _apply(self, setting):
|
||||||
await self.controller.app.wait_with_text_dialog(
|
await self.controller.app.wait_with_text_dialog(
|
||||||
|
@ -431,7 +430,7 @@ class KeyboardView(BaseView):
|
||||||
self.controller.done()
|
self.controller.done()
|
||||||
|
|
||||||
def really_done(self, setting):
|
def really_done(self, setting):
|
||||||
asyncio.create_task(self._apply(setting))
|
run_bg_task(self._apply(setting))
|
||||||
|
|
||||||
def cancel(self, result=None):
|
def cancel(self, result=None):
|
||||||
self.controller.cancel()
|
self.controller.cancel()
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
Provides device activation and configuration on s390x
|
Provides device activation and configuration on s390x
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from urwid import (
|
from urwid import (
|
||||||
|
@ -26,6 +25,7 @@ from urwid import (
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.ui.actionmenu import (
|
from subiquitycore.ui.actionmenu import (
|
||||||
ActionMenu,
|
ActionMenu,
|
||||||
)
|
)
|
||||||
|
@ -84,8 +84,7 @@ class ZdevList(WidgetWrap):
|
||||||
self.update(new_zdevinfos)
|
self.update(new_zdevinfos)
|
||||||
|
|
||||||
def zdev_action(self, sender, action, zdevinfo):
|
def zdev_action(self, sender, action, zdevinfo):
|
||||||
asyncio.create_task(
|
run_bg_task(self._zdev_action(action, zdevinfo))
|
||||||
self._zdev_action(action, zdevinfo))
|
|
||||||
|
|
||||||
def update(self, zdevinfos):
|
def update(self, zdevinfos):
|
||||||
rows = [TableRow([
|
rows = [TableRow([
|
||||||
|
|
|
@ -18,6 +18,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.context import (
|
from subiquitycore.context import (
|
||||||
Context,
|
Context,
|
||||||
)
|
)
|
||||||
|
@ -129,7 +130,7 @@ class Application:
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
self.base_model = self.make_model()
|
self.base_model = self.make_model()
|
||||||
asyncio.create_task(self.start())
|
run_bg_task(self.start())
|
||||||
await self.exit_event.wait()
|
await self.exit_event.wait()
|
||||||
if self._exc:
|
if self._exc:
|
||||||
exc, self._exc = self._exc, None
|
exc, self._exc = self._exc, None
|
||||||
|
|
|
@ -24,7 +24,10 @@ import urwid
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from subiquitycore.async_helpers import schedule_task
|
from subiquitycore.async_helpers import (
|
||||||
|
run_bg_task,
|
||||||
|
schedule_task,
|
||||||
|
)
|
||||||
from subiquitycore.core import Application
|
from subiquitycore.core import Application
|
||||||
from subiquitycore.palette import (
|
from subiquitycore.palette import (
|
||||||
PALETTE_COLOR,
|
PALETTE_COLOR,
|
||||||
|
@ -247,10 +250,10 @@ class TuiApplication(Application):
|
||||||
self.ui.set_body(view)
|
self.ui.set_body(view)
|
||||||
|
|
||||||
def next_screen(self, coro=None):
|
def next_screen(self, coro=None):
|
||||||
asyncio.create_task(self.move_screen(1, coro))
|
run_bg_task(self.move_screen(1, coro))
|
||||||
|
|
||||||
def prev_screen(self):
|
def prev_screen(self):
|
||||||
asyncio.create_task(self.move_screen(-1, None))
|
run_bg_task(self.move_screen(-1, None))
|
||||||
|
|
||||||
def select_initial_screen(self):
|
def select_initial_screen(self):
|
||||||
self.next_screen()
|
self.next_screen()
|
||||||
|
|
|
@ -19,7 +19,6 @@ Provides network device listings and extended network information
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from urwid import (
|
from urwid import (
|
||||||
|
@ -27,6 +26,7 @@ from urwid import (
|
||||||
Text,
|
Text,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.models.network import (
|
from subiquitycore.models.network import (
|
||||||
DHCPState,
|
DHCPState,
|
||||||
NetDevAction,
|
NetDevAction,
|
||||||
|
@ -297,7 +297,7 @@ class NetworkView(BaseView):
|
||||||
self.show_stretchy_overlay(stretchy)
|
self.show_stretchy_overlay(stretchy)
|
||||||
|
|
||||||
def _action_INFO(self, name, dev_info):
|
def _action_INFO(self, name, dev_info):
|
||||||
asyncio.create_task(
|
run_bg_task(
|
||||||
self._show_INFO(dev_info.name))
|
self._show_INFO(dev_info.name))
|
||||||
_action_INFO.opens_dialog = True
|
_action_INFO.opens_dialog = True
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
|
|
||||||
from subiquity.client.controller import SubiquityTuiController
|
from subiquity.client.controller import SubiquityTuiController
|
||||||
|
@ -25,7 +26,7 @@ class SummaryController(SubiquityTuiController):
|
||||||
self.summary_view = None
|
self.summary_view = None
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
asyncio.create_task(self._wait_status())
|
run_bg_task(self._wait_status())
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
self.app.cancel()
|
self.app.cancel()
|
||||||
|
@ -34,7 +35,7 @@ class SummaryController(SubiquityTuiController):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def click_reboot(self):
|
def click_reboot(self):
|
||||||
asyncio.create_task(self.send_reboot_and_wait())
|
run_bg_task(self.send_reboot_and_wait())
|
||||||
|
|
||||||
async def send_reboot_and_wait(self):
|
async def send_reboot_and_wait(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import enum
|
import enum
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from subiquitycore.async_helpers import run_bg_task
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquity.common.types import ShutdownMode
|
from subiquity.common.types import ShutdownMode
|
||||||
from subiquity.server.controllers import ShutdownController
|
from subiquity.server.controllers import ShutdownController
|
||||||
|
@ -40,8 +40,8 @@ class SetupShutdownController(ShutdownController):
|
||||||
self.mode = WSLShutdownMode.COMPLETE # allow the complete mode
|
self.mode = WSLShutdownMode.COMPLETE # allow the complete mode
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
asyncio.create_task(self._wait_install())
|
run_bg_task(self._wait_install())
|
||||||
asyncio.create_task(self._run())
|
run_bg_task(self._run())
|
||||||
|
|
||||||
async def _wait_install(self):
|
async def _wait_install(self):
|
||||||
await self.app.controllers.Install.install_task
|
await self.app.controllers.Install.install_task
|
||||||
|
|
Loading…
Reference in New Issue