lacuscore 1.7.5__py3-none-any.whl → 1.7.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lacuscore/lacuscore.py CHANGED
@@ -604,7 +604,9 @@ class LacusCore():
604
604
  except asyncio.CancelledError:
605
605
  logger.warning(f'The capture of {url} has been cancelled.')
606
606
  result = {'error': f'The capture of {url} has been cancelled.'}
607
- raise CaptureError
607
+ # The capture can be canceled if it has been running for way too long.
608
+ # We can give it another short.
609
+ raise RetryCapture
608
610
  except (TimeoutError, asyncio.exceptions.TimeoutError):
609
611
  logger.warning(f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)')
610
612
  result = {'error': f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)'}
@@ -790,8 +792,16 @@ class LacusCore():
790
792
  def clear_capture(self, uuid: str, reason: str):
791
793
  '''Remove a capture from the list, shouldn't happen unless it is in error'''
792
794
  logger = LacusCoreLogAdapter(self.master_logger, {'uuid': uuid})
793
- if self.get_capture_status(uuid) in [CaptureStatus.ONGOING, CaptureStatus.QUEUED]:
794
- logger.warning('Attempted to clear capture that is still being processed.')
795
+ capture_status = self.get_capture_status(uuid)
796
+ if capture_status == CaptureStatus.ONGOING:
797
+ # Check when it was started.
798
+ if start_time := self.redis.zscore('lacus:ongoing', uuid):
799
+ if start_time > time.time() - self.max_capture_time * 1.1:
800
+ # The capture started recently, wait before clearing it.
801
+ logger.warning('The capture is (probably) still going, not clearing.')
802
+ return
803
+ elif capture_status == CaptureStatus.QUEUED:
804
+ logger.warning('The capture is queued, not clearing.')
795
805
  return
796
806
  logger.warning(f'Clearing capture: {reason}')
797
807
  result: CaptureResponse = {'error': reason}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lacuscore
3
- Version: 1.7.5
3
+ Version: 1.7.7
4
4
  Summary: Core of Lacus, usable as a module
5
5
  Home-page: https://github.com/ail-project/LacusCore
6
6
  License: BSD-3-Clause
@@ -26,7 +26,7 @@ Provides-Extra: docs
26
26
  Requires-Dist: Sphinx (<7.2) ; (python_version < "3.9") and (extra == "docs")
27
27
  Requires-Dist: Sphinx (>=7.2,<8.0) ; (python_version >= "3.9") and (extra == "docs")
28
28
  Requires-Dist: defang (>=0.5.3,<0.6.0)
29
- Requires-Dist: playwrightcapture[recaptcha] (>=1.22.4,<2.0.0)
29
+ Requires-Dist: playwrightcapture[recaptcha] (>=1.22.5,<2.0.0)
30
30
  Requires-Dist: redis[hiredis] (>=5.0.1,<6.0.0)
31
31
  Requires-Dist: requests (>=2.31.0,<3.0.0)
32
32
  Requires-Dist: ua-parser (>=0.18.0,<0.19.0)
@@ -0,0 +1,8 @@
1
+ lacuscore/__init__.py,sha256=ytBrQRBXO1Q5yV72qyS16Q7Auqebl3EMhhLQUa0Sg4g,169
2
+ lacuscore/lacus_monitoring.py,sha256=3kbjz_ONjOXzaLzc8Vp7bUmEDKQDMi2uQgVSSfpqdXQ,2732
3
+ lacuscore/lacuscore.py,sha256=rxlO85jzeHbfQhzqO2qpAoJPZII5vAUHrbsIR0SUCeE,39687
4
+ lacuscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ lacuscore-1.7.7.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
6
+ lacuscore-1.7.7.dist-info/METADATA,sha256=vsMzvdv2h6le5KrOnSp2_Ppj9rpnPtLvohjd1M1BSwg,2514
7
+ lacuscore-1.7.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
8
+ lacuscore-1.7.7.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- lacuscore/__init__.py,sha256=ytBrQRBXO1Q5yV72qyS16Q7Auqebl3EMhhLQUa0Sg4g,169
2
- lacuscore/lacus_monitoring.py,sha256=3kbjz_ONjOXzaLzc8Vp7bUmEDKQDMi2uQgVSSfpqdXQ,2732
3
- lacuscore/lacuscore.py,sha256=006MUIMLdI-ZzTL2CbL9kM85kQknYjqWQA-hxQ0G7lY,39122
4
- lacuscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- lacuscore-1.7.5.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
6
- lacuscore-1.7.5.dist-info/METADATA,sha256=_4Rz7umz6gJqgbbWiv9-Q4b9crEF7SvmfzMc7IHgba0,2514
7
- lacuscore-1.7.5.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
8
- lacuscore-1.7.5.dist-info/RECORD,,