mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-11 23:42:38 +00:00
oops @log_call is not Deferred friendly
This commit is contained in:
parent
92cf9b8232
commit
436b91b463
@ -771,6 +771,20 @@ ALL_FILES = MessageType(
|
|||||||
u"A record of the rough state of the local database at the time of downloader start up.",
|
u"A record of the rough state of the local database at the time of downloader start up.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
START_DOWNLOADING = ActionType(
|
||||||
|
u"magic-folder:start-downloading",
|
||||||
|
[_NICKNAME, _DIRECTION],
|
||||||
|
[],
|
||||||
|
u"A Magic-Folder downloader is initializing and beginning to manage downloads.",
|
||||||
|
)
|
||||||
|
|
||||||
|
PERFORM_SCAN = ActionType(
|
||||||
|
u"magic-folder:perform-scan",
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
u"Remote storage is being scanned for changes which need to be synchronized.",
|
||||||
|
)
|
||||||
|
|
||||||
class QueueMixin(HookMixin):
|
class QueueMixin(HookMixin):
|
||||||
"""
|
"""
|
||||||
A parent class for Uploader and Downloader that handles putting
|
A parent class for Uploader and Downloader that handles putting
|
||||||
@ -1551,24 +1565,25 @@ class Downloader(QueueMixin, WriteFileMixin):
|
|||||||
self._status_reporter = status_reporter
|
self._status_reporter = status_reporter
|
||||||
self._poll_interval = poll_interval
|
self._poll_interval = poll_interval
|
||||||
|
|
||||||
@log_call
|
|
||||||
@eliotutil.inline_callbacks
|
@eliotutil.inline_callbacks
|
||||||
def start_downloading(self):
|
def start_downloading(self):
|
||||||
ALL_FILES.log(files=self._db.get_all_relpaths())
|
action = START_DOWNLOADING(**self._log_fields)
|
||||||
|
with action:
|
||||||
|
ALL_FILES.log(files=self._db.get_all_relpaths())
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data = yield self._scan_remote_collective(scan_self=True)
|
data = yield self._scan_remote_collective(scan_self=True)
|
||||||
self._begin_processing()
|
self._begin_processing()
|
||||||
defer.returnValue(data)
|
defer.returnValue(data)
|
||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
self._status_reporter(
|
self._status_reporter(
|
||||||
False, "Initial scan has failed",
|
False, "Initial scan has failed",
|
||||||
"Last tried at %s" % self.nice_current_time(),
|
"Last tried at %s" % self.nice_current_time(),
|
||||||
)
|
)
|
||||||
write_traceback()
|
write_traceback()
|
||||||
yield task.deferLater(self._clock, self._poll_interval, lambda: None)
|
yield task.deferLater(self._clock, self._poll_interval, lambda: None)
|
||||||
|
|
||||||
def nice_current_time(self):
|
def nice_current_time(self):
|
||||||
return format_time(datetime.fromtimestamp(self._clock.seconds()).timetuple())
|
return format_time(datetime.fromtimestamp(self._clock.seconds()).timetuple())
|
||||||
@ -1714,21 +1729,21 @@ class Downloader(QueueMixin, WriteFileMixin):
|
|||||||
def _scan_delay(self):
|
def _scan_delay(self):
|
||||||
return self._poll_interval
|
return self._poll_interval
|
||||||
|
|
||||||
@log_call
|
|
||||||
@eliotutil.inline_callbacks
|
@eliotutil.inline_callbacks
|
||||||
def _perform_scan(self):
|
def _perform_scan(self):
|
||||||
try:
|
with PERFORM_SCAN():
|
||||||
yield self._scan_remote_collective()
|
try:
|
||||||
self._status_reporter(
|
yield self._scan_remote_collective()
|
||||||
True, 'Magic folder is working',
|
self._status_reporter(
|
||||||
'Last scan: %s' % self.nice_current_time(),
|
True, 'Magic folder is working',
|
||||||
)
|
'Last scan: %s' % self.nice_current_time(),
|
||||||
except Exception as e:
|
)
|
||||||
write_traceback()
|
except Exception as e:
|
||||||
self._status_reporter(
|
write_traceback()
|
||||||
False, 'Remote scan has failed: %s' % str(e),
|
self._status_reporter(
|
||||||
'Last attempted at %s' % self.nice_current_time(),
|
False, 'Remote scan has failed: %s' % str(e),
|
||||||
)
|
'Last attempted at %s' % self.nice_current_time(),
|
||||||
|
)
|
||||||
|
|
||||||
def _process(self, item):
|
def _process(self, item):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user