def __init__(self, session): RESTEndpoint.__init__(self, session) TaskManager.__init__(self) self.events_responses = [] self.app.on_shutdown.append(self.on_shutdown) # We need to know that Tribler completed its startup sequence self.tribler_started = False self.session.notifier.add_observer(NTFY.TRIBLER_STARTED, self._tribler_started) for event_type, event_lambda in reactions_dict.items(): self.session.notifier.add_observer(event_type, lambda *args, el=event_lambda, et=event_type: self.write_data({"type": et.value, "event": el(*args)})) def on_circuit_removed(circuit, *args): if isinstance(circuit, Circuit): event = { "circuit_id": circuit.circuit_id, "bytes_up": circuit.bytes_up, "bytes_down": circuit.bytes_down, "uptime": time.time() - circuit.creation_time } self.write_data({"type": NTFY.TUNNEL_REMOVE.value, "event": event}) # Tribler tunnel circuit has been removed self.session.notifier.add_observer(NTFY.TUNNEL_REMOVE, on_circuit_removed)
def __init__(self, notifier: Notifier, public_key: str = None): RESTEndpoint.__init__(self) TaskManager.__init__(self) self.events_responses: List[RESTStreamResponse] = [] self.app.on_shutdown.append(self.on_shutdown) self.notifier = None self.undelivered_error: Optional[dict] = None self.connect_notifier(notifier) self.public_key = public_key
def __init__(self, working_dir, config_path): super().__init__(Service.create_config(working_dir, config_path), None, working_dir, config_path) TaskManager.__init__(self) self.swarm = None self.start = time.time() self.results = [] self.register_task('monitor_swarm', self.monitor_swarm, interval=5) self.register_task('_graceful_shutdown', self._graceful_shutdown, delay=EXPERIMENT_RUN_TIME)
def __init__(self, lt_session): """ Initialize the DHT health manager. :param lt_session: The session used to perform health lookups. """ TaskManager.__init__(self) self.lookup_futures = {} # Map from binary infohash to future self.bf_seeders = { } # Map from infohash to (final) seeders bloomfilter self.bf_peers = {} # Map from infohash to (final) peers bloomfilter self.lt_session = lt_session
def __init__(self, working_dir, config_path): super().__init__(Service.create_config(working_dir, config_path), working_dir=working_dir, components=[ Ipv8Component(), KeyComponent(), RESTComponent(), TunnelsComponent() ]) TaskManager.__init__(self) self.results = [] self.output_file = 'speed_test_exit.txt'
def __init__(self, session, history_size=CORE_RESOURCE_HISTORY_SIZE): TaskManager.__init__(self) ResourceMonitor.__init__(self, history_size=history_size) self.session = session self.disk_usage_data = deque(maxlen=history_size) self.state_dir = session.config.get_state_dir() self.resource_log_file = session.config.get_log_dir( ) / DEFAULT_RESOURCE_FILENAME self.resource_log_enabled = session.config.get_resource_monitor_enabled( ) # Setup yappi profiler self.profiler = YappiProfiler(self.session)
def __init__(self, state_dir, log_dir, config: ResourceMonitorSettings, notifier: Notifier, history_size=CORE_RESOURCE_HISTORY_SIZE): TaskManager.__init__(self) ResourceMonitor.__init__(self, history_size=history_size) self.config = config self.notifier = notifier self.disk_usage_data = deque(maxlen=history_size) self.state_dir = state_dir self.resource_log_file = log_dir / DEFAULT_RESOURCE_FILENAME self.resource_log_enabled = config.enabled # Setup yappi profiler self.profiler = YappiProfiler(log_dir)
def __init__(self, working_dir, config_path): super().__init__(Service.create_config(working_dir, config_path), None, working_dir, config_path) TaskManager.__init__(self) self.results = [] self.output_file = 'speed_test_exit.txt'