From 59c35df0676977c93ed7276237179c9af8d9c476 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Tue, 26 Apr 2022 17:13:47 +0200 Subject: Optimized a bunch of partprobe calls. (#1088) * Optimized a bunch of partprobe calls. Namely fixed sleep calls, added optional path to the general archinstall.partprobe() call. And fixed some error handling in a few places which should tell us where #1083 might be going wrong. * Fixed some flake8 complaints * Fixed sleep having a min() of 0.1 or given value. * Fixed sleep having a correct range variable. * Fixed sleep logic to use max() instead of min() as it will never use the higer sleep values otheride --- archinstall/lib/disk/helpers.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'archinstall/lib/disk/helpers.py') diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py index 2f73b2bd..f9618b6c 100644 --- a/archinstall/lib/disk/helpers.py +++ b/archinstall/lib/disk/helpers.py @@ -418,16 +418,20 @@ def find_partition_by_mountpoint(block_devices :List[BlockDevice], relative_moun if partition.get('mountpoint', None) == relative_mountpoint: return partition -def partprobe() -> bool: - if SysCommand(f'bash -c "partprobe"').exit_code == 0: - time.sleep(5) # TODO: Remove, we should be relying on blkid instead of lsblk - return True +def partprobe(path :str = '') -> bool: + try: + if SysCommand(f'bash -c "partprobe {path}"').exit_code == 0: + return True + except SysCallError: + pass return False def convert_device_to_uuid(path :str) -> str: device_name, bind_name = split_bind_name(path) + for i in range(storage['DISK_RETRY_ATTEMPTS']): - partprobe() + partprobe(device_name) + time.sleep(max(0.1, storage['DISK_TIMEOUTS'] * i)) # TODO: Remove, we should be relying on blkid instead of lsblk # TODO: Convert lsblk to blkid # (lsblk supports BlockDev and Partition UUID grabbing, blkid requires you to pick PTUUID and PARTUUID) @@ -437,8 +441,6 @@ def convert_device_to_uuid(path :str) -> str: if (dev_uuid := device.get('uuid', None)): return dev_uuid - time.sleep(storage['DISK_TIMEOUTS']) - raise DiskError(f"Could not retrieve the UUID of {path} within a timely manner.") def has_mountpoint(partition: Union[dict,Partition,MapperDev], target: str, strict: bool = True) -> bool: -- cgit v1.2.3-70-g09d2