Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions qubes/storage/reflink.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ def _coroutinized(function):

@functools.wraps(function)
async def wrapper(*args, **kwargs):
return await asyncio.get_event_loop().run_in_executor(
None, functools.partial(function, *args, **kwargs)
)
return await asyncio.to_thread(function, *args, **kwargs)

return wrapper

Expand Down
6 changes: 1 addition & 5 deletions qubes/storage/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2044,11 +2044,7 @@ async def _wipe_and_clone_from(self, source: qubes.storage.Volume) -> None:
self.log.debug("Source is a File volume")
# File volume export() does not actually return a coroutine.
# This isn't just a typing error. The await() fails.
loop = asyncio.get_event_loop()
in_ = await loop.run_in_executor(
None,
source.export,
) # type:ignore
in_ = await asyncio.to_thread(source.export) # type:ignore
else:
self.log.debug("Source is not a ZFS volume")
in_ = await source.export() # type:ignore
Expand Down
13 changes: 4 additions & 9 deletions qubes/tests/integ/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,11 @@ def restore_backup(
client_app = qubesadmin.Qubes()
if appvm:
appvm = self.loop.run_until_complete(
self.loop.run_in_executor(
None, client_app.domains.__getitem__, appvm.name
)
asyncio.to_thread(client_app.domains.__getitem__, appvm.name)
)
with self.assertNotRaises(qubesadmin.exc.QubesException):
restore_op = self.loop.run_until_complete(
self.loop.run_in_executor(
None,
asyncio.to_thread(
qubesadmin.backup.restore.BackupRestore,
client_app,
backupfile,
Expand All @@ -269,17 +266,15 @@ def restore_backup(
for key, value in options.items():
setattr(restore_op.options, key, value)
restore_info = self.loop.run_until_complete(
self.loop.run_in_executor(None, restore_op.get_restore_info)
asyncio.to_thread(restore_op.get_restore_info)
)
if callable(manipulate_restore_info):
restore_info = manipulate_restore_info(restore_info)
self.log.debug(restore_op.get_restore_summary(restore_info))

with self.assertNotRaises(qubesadmin.exc.QubesException):
self.loop.run_until_complete(
self.loop.run_in_executor(
None, restore_op.restore_do, restore_info
)
asyncio.to_thread(restore_op.restore_do, restore_info)
)

errors = []
Expand Down
2 changes: 1 addition & 1 deletion qubes/tests/integ/backupdispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def restore_backup(
restore_in_dispvm = RestoreInDisposableVM(args.app, args)
try:
backup_log = self.loop.run_until_complete(
self.loop.run_in_executor(None, restore_in_dispvm.run)
asyncio.to_thread(restore_in_dispvm.run)
)
except qubesadmin.exc.BackupRestoreError as e:
self.fail(str(e) + " backup log: " + e.backup_log.decode())
Expand Down
6 changes: 2 additions & 4 deletions qubes/tests/integ/vm_qrexec_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,7 @@ async def _test_300_bug_1028_gui_memory_pinning(self):
winid = await self.wait_for_window_coro(
self.testvm1.name + ":xterm", search_class=True
)
xprop = await asyncio.get_event_loop().run_in_executor(
None,
xprop = await asyncio.to_thread(
subprocess.check_output,
["xprop", "-notype", "-id", winid, "_QUBES_VMWINDOWID"],
)
Expand Down Expand Up @@ -850,8 +849,7 @@ async def _test_300_bug_1028_gui_memory_pinning(self):
"gm import -window {} rgba:-".format(vm_winid)
)

dom0_image = await asyncio.get_event_loop().run_in_executor(
None,
dom0_image = await asyncio.to_thread(
subprocess.check_output,
["gm", "import", "-window", winid, "rgba:-"],
)
Expand Down
9 changes: 5 additions & 4 deletions qubes/vm/dispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,10 +626,11 @@ async def on_domain_pre_paused(self, event, **kwargs) -> None:
return
break_task = asyncio.create_task(self.preload_requested_event.wait())
qmemman_client = qubes.qmemman.client.QMemmanClient()
qmemman_task = asyncio.get_running_loop().run_in_executor(
None,
qmemman_client.set_mem, # type: ignore[arg-type]
{self.xid: 0},
qmemman_task = asyncio.create_task(
asyncio.to_thread(
qmemman_client.set_mem,
{self.xid: 0},
)
)
tasks: list = [break_task, qmemman_task]
result = None
Expand Down
4 changes: 2 additions & 2 deletions qubes/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,8 +1453,8 @@ async def start(
notify_function=notify_function,
)

qmemman_client = await asyncio.get_event_loop().run_in_executor(
None, self.request_mem, mem_required
qmemman_client = await asyncio.to_thread(
self.request_mem, mem_required
)

await self.storage.start()
Expand Down