start lbry files in parallel
This commit is contained in:
parent
43c73b9abf
commit
f94a9e8729
1 changed files with 35 additions and 28 deletions
|
@ -97,16 +97,7 @@ class EncryptedFileManager(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _start_lbry_files(self):
|
def _start_lbry_file(self, file_info, payment_rate_manager):
|
||||||
files = yield self.session.storage.get_all_lbry_files()
|
|
||||||
b_prm = self.session.base_payment_rate_manager
|
|
||||||
payment_rate_manager = NegotiatedPaymentRateManager(b_prm, self.session.blob_tracker)
|
|
||||||
|
|
||||||
log.info("Trying to start %i files", len(files))
|
|
||||||
for i, file_info in enumerate(files):
|
|
||||||
if len(files) > 500 and i % 500 == 0:
|
|
||||||
log.info("Started %i/%i files", i, len(files))
|
|
||||||
|
|
||||||
lbry_file = self._get_lbry_file(
|
lbry_file = self._get_lbry_file(
|
||||||
file_info['row_id'], file_info['stream_hash'], payment_rate_manager, file_info['sd_hash'],
|
file_info['row_id'], file_info['stream_hash'], payment_rate_manager, file_info['sd_hash'],
|
||||||
file_info['key'], file_info['stream_name'], file_info['file_name'], file_info['download_directory'],
|
file_info['key'], file_info['stream_name'], file_info['file_name'], file_info['download_directory'],
|
||||||
|
@ -129,8 +120,24 @@ class EncryptedFileManager(object):
|
||||||
lbry_file.restore(file_info['status'])
|
lbry_file.restore(file_info['status'])
|
||||||
self.storage.content_claim_callbacks[lbry_file.stream_hash] = lbry_file.get_claim_info
|
self.storage.content_claim_callbacks[lbry_file.stream_hash] = lbry_file.get_claim_info
|
||||||
self.lbry_files.append(lbry_file)
|
self.lbry_files.append(lbry_file)
|
||||||
|
if len(self.lbry_files) % 500 == 0:
|
||||||
|
log.info("Started %i files", len(self.lbry_files))
|
||||||
except Exception:
|
except Exception:
|
||||||
log.warning("Failed to start %i", file_info.get('rowid'))
|
log.warning("Failed to start %i", file_info.get('rowid'))
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def _start_lbry_files(self):
|
||||||
|
files = yield self.session.storage.get_all_lbry_files()
|
||||||
|
b_prm = self.session.base_payment_rate_manager
|
||||||
|
payment_rate_manager = NegotiatedPaymentRateManager(b_prm, self.session.blob_tracker)
|
||||||
|
|
||||||
|
log.info("Starting %i files", len(files))
|
||||||
|
dl = []
|
||||||
|
for file_info in files:
|
||||||
|
dl.append(self._start_lbry_file(file_info, payment_rate_manager))
|
||||||
|
|
||||||
|
yield defer.DeferredList(dl)
|
||||||
|
|
||||||
log.info("Started %i lbry files", len(self.lbry_files))
|
log.info("Started %i lbry files", len(self.lbry_files))
|
||||||
if self.auto_re_reflect is True:
|
if self.auto_re_reflect is True:
|
||||||
safe_start_looping_call(self.lbry_file_reflector, self.auto_re_reflect_interval)
|
safe_start_looping_call(self.lbry_file_reflector, self.auto_re_reflect_interval)
|
||||||
|
|
Loading…
Add table
Reference in a new issue