예제 #1
0
    def stop(self):
        if self.__state == TorrentState.Stopping:
            return

        Logger().write(LogVerbosity.Info, 'Torrent stopping')
        self.__set_state(TorrentState.Stopping)
        EventManager.deregister_event(self._user_file_selected_id)

        self.engine.stop()
        Logger().write(LogVerbosity.Debug, 'Torrent engines stopped')

        self.peer_processor.stop()
        self.peer_manager.stop()
        self.tracker_manager.stop()
        self.network_manager.stop()
        self.metadata_manager.stop()
        self.stream_manager.stop()
        self.message_processor.stop()
        self.download_manager.stop()
        self.data_manager.stop()
        self.cache_manager.stop()
        Logger().write(LogVerbosity.Debug, 'Torrent managers stopped')

        for file in self.files:
            file.close()

        self.files = []
        self.media_file = None

        self.finish()
        EventManager.throw_event(EventType.TorrentStopped, [])
        Logger().write(LogVerbosity.Important, 'Torrent stopped')
예제 #2
0
 def wait_for_event(max_time, event):
     UtilController.health_cache[event] = False
     evnt = EventManager.register_event(
         event, lambda *x: UtilController.assign(event))
     result = UtilController.wait_for(
         max_time, lambda: UtilController.health_cache[event])
     EventManager.deregister_event(evnt)
     return result
예제 #3
0
 def unregister(self):
     EventManager.deregister_event(self._event_id_stopped)
예제 #4
0
 def unregister(self):
     EventManager.deregister_event(self._event_id_stopped)
     EventManager.deregister_event(self._event_id_torrent_change)
     EventManager.deregister_event(self._event_id_peers_found)
예제 #5
0
 def stop(self):
     EventManager.deregister_event(self.request_peers_id)