1+ from __future__ import annotations
2+
13import time
24from collections .abc import Iterator
35from types import TracebackType
4- from typing import Self
6+ from typing import TYPE_CHECKING , ClassVar , Self
57
68from .exceptions import SysCallError
79from .general import SysCommand , SysCommandWorker , locate_binary
8- from .installer import Installer
910from .output import error
10- from .storage import storage
11+
12+ if TYPE_CHECKING :
13+ from .installer import Installer
1114
1215
1316class Boot :
17+ _active_boot : ClassVar [Self | None ] = None
18+
1419 def __init__ (self , installation : Installer ):
1520 self .instance = installation
1621 self .container_name = 'archinstall'
1722 self .session : SysCommandWorker | None = None
1823 self .ready = False
1924
2025 def __enter__ (self ) -> Self :
21- if ( existing_session := storage . get ( 'active_boot' , None )) and existing_session .instance != self .instance :
26+ if Boot . _active_boot and Boot . _active_boot .instance != self .instance :
2227 raise KeyError ('Archinstall only supports booting up one instance and another session is already active.' )
2328
24- if existing_session :
25- self .session = existing_session .session
26- self .ready = existing_session .ready
29+ if Boot . _active_boot :
30+ self .session = Boot . _active_boot .session
31+ self .ready = Boot . _active_boot .ready
2732 else :
2833 # '-P' or --console=pipe could help us not having to do a bunch
2934 # of os.write() calls, but instead use pipes (stdin, stdout and stderr) as usual.
@@ -46,7 +51,7 @@ def __enter__(self) -> Self:
4651 self .ready = True
4752 break
4853
49- storage [ 'active_boot' ] = self
54+ Boot . _active_boot = self
5055 return self
5156
5257 def __exit__ (self , exc_type : type [BaseException ] | None , exc_value : BaseException | None , traceback : TracebackType | None ) -> None :
@@ -75,7 +80,7 @@ def __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseExceptio
7580 shutdown_exit_code = shutdown .exit_code
7681
7782 if self .session and (self .session .exit_code == 0 or shutdown_exit_code == 0 ):
78- storage [ 'active_boot' ] = None
83+ Boot . _active_boot = None
7984 else :
8085 session_exit_code = self .session .exit_code if self .session else - 1
8186
0 commit comments