diff options
Diffstat (limited to 'modules/zfssnap')
-rw-r--r-- | modules/zfssnap/zfssnap.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/zfssnap/zfssnap.py b/modules/zfssnap/zfssnap.py index a8ad231c..b53c6b17 100644 --- a/modules/zfssnap/zfssnap.py +++ b/modules/zfssnap/zfssnap.py | |||
@@ -25,6 +25,8 @@ from functools import cache | |||
25 | 25 | ||
26 | from math import floor | 26 | from math import floor |
27 | 27 | ||
28 | import asyncio | ||
29 | |||
28 | 30 | ||
29 | @cache | 31 | @cache |
30 | def _now(): | 32 | def _now(): |
@@ -234,7 +236,7 @@ def autosnap(): | |||
234 | pass | 236 | pass |
235 | 237 | ||
236 | all_snap_names = set() | 238 | all_snap_names = set() |
237 | def do_snapshot(*snap_items, recursive=False): | 239 | async def do_snapshot(*snap_items, recursive=False): |
238 | nonlocal items, all_snap_names | 240 | nonlocal items, all_snap_names |
239 | snap_names = {_snap_name(item) for item in snap_items} | 241 | snap_names = {_snap_name(item) for item in snap_items} |
240 | if recursive: | 242 | if recursive: |
@@ -251,12 +253,16 @@ def autosnap(): | |||
251 | _log_cmd(*args) | 253 | _log_cmd(*args) |
252 | subprocess.run(args, check=True) | 254 | subprocess.run(args, check=True) |
253 | 255 | ||
256 | tasks = [] | ||
254 | if single: | 257 | if single: |
255 | do_snapshot(*single) | 258 | tasks.append(asyncio.create_task(do_snapshot(*single))) |
256 | if recursive: | 259 | if recursive: |
257 | do_snapshot(*recursive, recursive=True) | 260 | tasks.append(asyncio.create_task(do_snapshot(*recursive, recursive=True))) |
258 | if not single and not recursive: | 261 | if not tasks: |
259 | logger.warning('No snapshots to create') | 262 | logger.warning('No snapshots to create') |
263 | else: | ||
264 | for task in tasks: | ||
265 | await task | ||
260 | for snap in all_snap_names: | 266 | for snap in all_snap_names: |
261 | logger.info(f'Created ‘{snap}’') | 267 | logger.info(f'Created ‘{snap}’') |
262 | if all_snap_names: | 268 | if all_snap_names: |