forked from LBRYCommunity/lbry-sdk
fix hash announcer semaphore
This commit is contained in:
parent
537df6c8ad
commit
b0a741b1f4
1 changed files with 4 additions and 2 deletions
|
@ -18,6 +18,7 @@ class DHTHashAnnouncer(object):
|
||||||
self.concurrent_announcers = concurrent_announcers or conf.settings['concurrent_announcers']
|
self.concurrent_announcers = concurrent_announcers or conf.settings['concurrent_announcers']
|
||||||
self._manage_lc = task.LoopingCall(self.manage)
|
self._manage_lc = task.LoopingCall(self.manage)
|
||||||
self._manage_lc.clock = self.clock
|
self._manage_lc.clock = self.clock
|
||||||
|
self.sem = defer.DeferredSemaphore(self.concurrent_announcers)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
self._manage_lc.start(30)
|
self._manage_lc.start(30)
|
||||||
|
@ -55,8 +56,9 @@ class DHTHashAnnouncer(object):
|
||||||
progress_lc = task.LoopingCall(self._show_announce_progress, len(self.hash_queue), start)
|
progress_lc = task.LoopingCall(self._show_announce_progress, len(self.hash_queue), start)
|
||||||
progress_lc.clock = self.clock
|
progress_lc.clock = self.clock
|
||||||
progress_lc.start(60, now=False)
|
progress_lc.start(60, now=False)
|
||||||
s = defer.DeferredSemaphore(self.concurrent_announcers)
|
results = yield utils.DeferredDict(
|
||||||
results = yield utils.DeferredDict({blob_hash: s.run(self.do_store, blob_hash) for blob_hash in blob_hashes})
|
{blob_hash: self.sem.run(self.do_store, blob_hash) for blob_hash in blob_hashes}
|
||||||
|
)
|
||||||
now = self.clock.seconds()
|
now = self.clock.seconds()
|
||||||
|
|
||||||
progress_lc.stop()
|
progress_lc.stop()
|
||||||
|
|
Loading…
Reference in a new issue