From: Daira Hopwood Date: Thu, 30 Jul 2015 17:04:44 +0000 (+0100) Subject: Move uploader's _append_to_deque and _turn_deque to QueueMixin. X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/module-simplejson.tests.html?a=commitdiff_plain;h=a8ccfea1515df02f31af5282a4daf17a13318d6b;p=tahoe-lafs%2Ftahoe-lafs.git Move uploader's _append_to_deque and _turn_deque to QueueMixin. Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 97b3de02..0f24c548 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -113,6 +113,25 @@ class QueueMixin(object): #print "_log %s" % (msg,) #open("events", "ab+").write(msg) + def _append_to_deque(self, path): + if path in self._pending: + return + self._deque.append(path) + self._pending.add(path) + self._count('objects_queued') + if self.is_ready: + reactor.callLater(0, self._turn_deque) + + def _turn_deque(self): + try: + path = self._deque.pop() + except IndexError: + self._log("magic folder upload deque is now empty") + self._lazy_tail = defer.succeed(None) + return + self._lazy_tail.addCallback(lambda ign: task.deferLater(reactor, 0, self._process, path)) + self._lazy_tail.addCallback(lambda ign: self._turn_deque()) + def _do_callback(self, res): if self._ignore_count == 0: self._callback(res) @@ -246,27 +265,6 @@ class Uploader(QueueMixin): return d - # FIXME move to QueueMixin - def _append_to_deque(self, path): - if path in self._pending: - return - self._deque.append(path) - self._pending.add(path) - self._counter('magic_folder.objects_queued', 1) - if self.is_ready: - reactor.callLater(0, self._turn_deque) - - # FIXME move to QueueMixin - def _turn_deque(self): - try: - path = self._deque.pop() - except IndexError: - self._log("magic folder upload deque is now empty") - self._lazy_tail = defer.succeed(None) - return - self._lazy_tail.addCallback(lambda ign: task.deferLater(reactor, 0, self._process, path)) - self._lazy_tail.addCallback(lambda ign: self._turn_deque()) - def _notify(self, opaque, path, events_mask): self._log("inotify event %r, %r, %r\n" % (opaque, path, ', '.join(self._inotify.humanReadableMask(events_mask)))) path_u = unicode_from_filepath(path)