fix hash announcer semaphore

This commit is contained in:
Jack Robison 2018-06-06 17:11:27 -04:00
parent 537df6c8ad
commit b0a741b1f4
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -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()