def initialize(self, save_path, files): # a list of bytes ranges and filenames for window-based IO self.ranges = [] # a dict of filename-to-ranges for piece priorities and filename lookup self.range_by_name = {} # a sparse set for smart allocation detection self.allocated_regions = SparseSet() # dict of filename-to-length on disk (for % complete in the file view) self.undownloaded = {} self.save_path = save_path # Rather implement this as an ugly hack here than change all the # individual calls. Affects all torrent instances using this module. if self.config['bad_libc_workaround']: bad_libc_workaround() self.initialized = False self.startup_df = ThreadedDeferred(_wrap_task(self.external_add_task), self._build_file_structs, self.filepool, files) return self.startup_df
def write(self, pos, s): df = launch_coroutine(_wrap_task(self.add_task), self._batch_write, pos, s) return df
def read(self, pos, amount): df = launch_coroutine(_wrap_task(self.add_task), self._batch_read, pos, amount) return df
def initialize_torrents(self): df = launch_coroutine(_wrap_task(self.rawserver.add_task), self._initialize_torrents) df.addErrback(lambda f : self.logger.error('initialize_torrents failed!', exc_info=f.exc_info())) return df
def shutdown(self): df = launch_coroutine(_wrap_task(self.rawserver.add_task), self._shutdown) df.addErrback(lambda f : self.logger.error('shutdown failed!', exc_info=f.exc_info())) return df