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: 2 additions & 2 deletions archinstall/lib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ def _verify_service_stop(self, offline: bool, skip_ntp: bool, skip_wkd: bool) ->
if not skip_ntp:
info(tr('Waiting for time sync (timedatectl show) to complete.'))

started_wait = time.time()
started_wait = time.monotonic()
notified = False
while True:
if not notified and time.time() - started_wait > 5:
if not notified and time.monotonic() - started_wait > 5:
notified = True
warn(tr('Time synchronization not completing, while you wait - check the docs for workarounds: https://archinstall.readthedocs.io/'))

Expand Down
10 changes: 5 additions & 5 deletions archinstall/lib/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def __enter__(self) -> Self:
self.previous_handler = signal.signal(signal.SIGALRM, self.raise_timeout) # type: ignore[assignment]
self.previous_timer = signal.alarm(self.timeout)

self.start_time = time.time()
self.start_time = time.monotonic()
return self

def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None) -> None:
if self.start_time:
time_delta = time.time() - self.start_time
time_delta = time.monotonic() - self.start_time
signal.alarm(0)
self.time = time_delta
if self.timeout > 0:
Expand Down Expand Up @@ -165,7 +165,7 @@ def build_icmp(payload: bytes) -> bytes:

def ping(hostname: str, timeout: int = 5) -> int:
watchdog = select.epoll()
started = time.time()
started = time.monotonic()
random_identifier = f'archinstall-{random.randint(1000, 9999)}'.encode()

# Create a raw socket (requires root, which should be fine on archiso)
Expand All @@ -180,15 +180,15 @@ def ping(hostname: str, timeout: int = 5) -> int:

# Gracefully wait for X amount of time
# for a ICMP response or exit with no latency
while latency == -1 and time.time() - started < timeout:
while latency == -1 and time.monotonic() - started < timeout:
try:
for _fileno, _event in watchdog.poll(0.1):
response, _ = icmp_socket.recvfrom(1024)
icmp_type = struct.unpack('!B', response[20:21])[0]

# Check if it's an Echo Reply (ICMP type 0)
if icmp_type == 0 and response[-len(random_identifier) :] == random_identifier:
latency = round((time.time() - started) * 1000)
latency = round((time.monotonic() - started) * 1000)
break
except OSError as e:
debug(f'Error: {e}')
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/pacman/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def run(args: str, default_cmd: str = 'pacman') -> SysCommand:
if pacman_db_lock.exists():
warn(tr('Pacman is already running, waiting maximum 10 minutes for it to terminate.'))

started = time.time()
started = time.monotonic()
while pacman_db_lock.exists():
time.sleep(0.25)

if time.time() - started > (60 * 10):
if time.monotonic() - started > (60 * 10):
error(tr('Pre-existing pacman lock never exited. Please clean up any existing pacman sessions before using archinstall.'))
sys.exit(1)

Expand Down