convert _notify
This commit is contained in:
parent
bfb039c6c6
commit
c3e50a4536
|
@ -685,6 +685,12 @@ SCAN = ActionType(
|
|||
u"A brute-force scan of a subset of the local directory is being performed.",
|
||||
)
|
||||
|
||||
NOTIFIED = ActionType(
|
||||
u"magic-folder:notified",
|
||||
[PATH, _NICKNAME, _DIRECTION],
|
||||
[],
|
||||
u"Magic-Folder received a notification of a local filesystem change for a certain path.",
|
||||
)
|
||||
|
||||
class QueueMixin(HookMixin):
|
||||
"""
|
||||
|
@ -1080,13 +1086,11 @@ class Uploader(QueueMixin):
|
|||
return relpath_u in self._pending
|
||||
|
||||
def _notify(self, opaque, path, events_mask):
|
||||
# Twisted doesn't seem to do anything if our callback throws
|
||||
# an error, so...
|
||||
try:
|
||||
return self._real_notify(opaque, path, events_mask)
|
||||
except Exception as e:
|
||||
self._log(u"error calling _real_notify: {}".format(e))
|
||||
twlog.err(Failure(), "Error calling _real_notify")
|
||||
with NOTIFIED(path=path, **self._log_fields):
|
||||
try:
|
||||
return self._real_notify(opaque, path, events_mask)
|
||||
except Exception:
|
||||
write_traceback()
|
||||
|
||||
def _real_notify(self, opaque, path, events_mask):
|
||||
self._log("inotify event %r, %r, %r\n" % (opaque, path, ', '.join(self._inotify.humanReadableMask(events_mask))))
|
||||
|
|
|
@ -1789,7 +1789,8 @@ class SingleMagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, Reall
|
|||
# pending callbacks including the exception are processed
|
||||
# before we flush the errors.
|
||||
yield task.deferLater(reactor, 0, lambda: None)
|
||||
errors = self.flushLoggedErrors(BadStuff)
|
||||
|
||||
errors = self.eliot_logger.flushTracebacks(BadStuff)
|
||||
# it seems on Windows the "RealTest" variant only produces 1
|
||||
# notification for some reason..
|
||||
self.assertTrue(len(errors) >= 1)
|
||||
|
|
Loading…
Reference in New Issue