Skip to content

Commit e6e48c6

Browse files
committed
fix: [crawler] debug crawler queued capture loop
1 parent 80c7410 commit e6e48c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

bin/crawlers/Crawler.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def get_message(self):
147147
if capture:
148148
try:
149149
status = self.lacus.get_capture_status(capture.uuid)
150+
print(status)
150151
if status == crawlers.CaptureStatus.DONE:
151152
return capture
152153
elif status == crawlers.CaptureStatus.UNKNOWN:
@@ -164,7 +165,10 @@ def get_message(self):
164165
self.logger.warning(f'capture UNKNOWN Timeout, {task.uuid} Send back in queue')
165166
else:
166167
capture.update(status)
167-
elif status == crawlers.CaptureStatus.QUEUED or status == crawlers.CaptureStatus.ONGOING:
168+
elif status == crawlers.CaptureStatus.QUEUED:
169+
capture.update(status, delta=30)
170+
print(capture.uuid, crawlers.CaptureStatus(status).name, int(time.time() + 30))
171+
elif status == crawlers.CaptureStatus.ONGOING:
168172
capture.update(status)
169173
print(capture.uuid, crawlers.CaptureStatus(status).name, int(time.time()))
170174
# Invalid State

bin/lib/crawlers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1531,13 +1531,13 @@ def create(self, task_uuid):
15311531
r_crawler.zadd('crawler:captures', {self.uuid: launch_time})
15321532
r_cache.zadd('crawler:captures', {self.uuid: launch_time})
15331533

1534-
def update(self, status):
1534+
def update(self, status, delta=0):
15351535
# Error or Reload
15361536
if not status:
15371537
r_cache.hset(f'crawler:capture:{self.uuid}', 'status', CaptureStatus.UNKNOWN.value)
15381538
r_cache.zadd('crawler:captures', {self.uuid: 0})
15391539
else:
1540-
last_check = int(time.time())
1540+
last_check = int(time.time() + delta)
15411541
r_cache.hset(f'crawler:capture:{self.uuid}', 'status', status)
15421542
r_cache.zadd('crawler:captures', {self.uuid: last_check})
15431543

0 commit comments

Comments
 (0)