def __init__(self): '''Initializes the backend manager. .. py:attribute:: state The :py:class:`BackendManager`'s current state. .. py:attribute:: state_lock Recursive lock to mediate access to :py:attr:`state`. .. py:attribute:: action_lock Hard lock to serialize backend life cycle actions. This lock is acquired while initializing and shutting down the backend. .. py:attribute:: src_inspector The source inspector object, :py:class:`Inspector`. .. py:attribute:: current_backend_name The name of the current backend. This starts out as the default backend's name, but can be changed to a different backend name. .. py:attribute:: possible_backends Filtered list of backend names. This is a subset of the *backends* settings, filtered on whether the backend's *type* is avaiable. For example, if *hsdev* is not installed (not available), then none of the *hsdev* backend names are possible (and not in this list). .. py:attribute:: project_cache A mapping between project names and files associated with each project. ''' super().__init__() BackendManager.ACTIVE_BACKEND = Backend.NullHaskellBackend(self) self.state = self.INITIAL self.state_lock = threading.RLock() self.action_lock = threading.Lock() self.src_inspector = Inspector.Inspector(BackendManager.ACTIVE_BACKEND) self.current_backend_name = BackendManager.ACTIVE_BACKEND.backend_name( ) self.possible_backends = {} self.project_cache = {}
def set_backend(self, new_backend): BackendManager.ACTIVE_BACKEND = new_backend with Inspector.Inspector(new_backend) as insp: self.src_inspector = insp insp.start_inspect()