lacuscore 1.9.4__py3-none-any.whl → 1.9.5__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
@@ -533,13 +533,12 @@ class LacusCore():
533
533
  browser_engine = 'webkit'
534
534
  try:
535
535
  logger.debug(f'Capturing {url}')
536
- general_timeout = to_capture.get('general_timeout_in_sec')
537
536
  stats_pipeline.sadd(f'stats:{today}:captures', url)
538
537
  async with Capture(
539
538
  browser=browser_engine,
540
539
  device_name=to_capture.get('device_name'),
541
540
  proxy=proxy,
542
- general_timeout_in_sec=general_timeout,
541
+ general_timeout_in_sec=to_capture.get('general_timeout_in_sec'),
543
542
  loglevel=self.master_logger.getEffectiveLevel(),
544
543
  uuid=uuid) as capture:
545
544
  # required by Mypy: https://github.com/python/mypy/issues/3004
@@ -552,27 +551,30 @@ class LacusCore():
552
551
  capture.timezone_id = to_capture.get('timezone_id') # type: ignore[assignment]
553
552
  capture.locale = to_capture.get('locale') # type: ignore[assignment]
554
553
  capture.color_scheme = to_capture.get('color_scheme') # type: ignore[assignment]
554
+
555
+ # make sure the initialization doesn't take too long
556
+ init_timeout = max(self.max_capture_time / 10, 5)
555
557
  try:
556
- # make sure the initialization doesn't take too long
557
- if general_timeout is None:
558
- general_timeout = 5
559
- init_timeout = max(general_timeout / 2, 5)
560
558
  async with timeout(init_timeout) as initialize_timeout:
561
559
  await capture.initialize_context()
562
-
563
560
  except (TimeoutError, asyncio.exceptions.TimeoutError):
564
561
  timeout_expired(initialize_timeout, logger, 'Initializing took too long.')
565
- logger.warning(f'Initializing the context for {url} took longer than the allowed general timeout ({general_timeout}s)')
566
- raise RetryCapture(f'Initializing the context for {url} took longer than the allowed general timeout ({general_timeout}s)')
567
-
568
- async with timeout(self.max_capture_time) as capture_timeout:
569
- playwright_result = await capture.capture_page(
570
- url, referer=to_capture.get('referer'),
571
- depth=to_capture.get('depth', 0),
572
- rendered_hostname_only=to_capture.get('rendered_hostname_only', True),
573
- with_favicon=to_capture.get('with_favicon', False),
574
- allow_tracking=to_capture.get('allow_tracking', False),
575
- max_depth_capture_time=self.max_capture_time)
562
+ logger.warning(f'Initializing the context for {url} took longer than the allowed initialization timeout ({init_timeout}s)')
563
+ raise RetryCapture(f'Initializing the context for {url} took longer than the allowed initialization timeout ({init_timeout}s)')
564
+
565
+ try:
566
+ async with timeout(self.max_capture_time) as capture_timeout:
567
+ playwright_result = await capture.capture_page(
568
+ url, referer=to_capture.get('referer'),
569
+ depth=to_capture.get('depth', 0),
570
+ rendered_hostname_only=to_capture.get('rendered_hostname_only', True),
571
+ with_favicon=to_capture.get('with_favicon', False),
572
+ allow_tracking=to_capture.get('allow_tracking', False),
573
+ max_depth_capture_time=self.max_capture_time)
574
+ except (TimeoutError, asyncio.exceptions.TimeoutError):
575
+ timeout_expired(capture_timeout, logger, 'Capture took too long.')
576
+ logger.warning(f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)')
577
+ raise RetryCapture(f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)')
576
578
  result = cast(CaptureResponse, playwright_result)
577
579
  if 'error' in result and 'error_name' in result:
578
580
  # generate stats
@@ -590,11 +592,6 @@ class LacusCore():
590
592
  # The capture can be canceled if it has been running for way too long.
591
593
  # We can give it another short.
592
594
  raise RetryCapture(f'The capture of {url} has been cancelled.')
593
- except (TimeoutError, asyncio.exceptions.TimeoutError):
594
- timeout_expired(capture_timeout, logger, 'Capture took too long.')
595
- logger.warning(f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)')
596
- result = {'error': f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)'}
597
- raise CaptureError(f'The capture of {url} took longer than the allowed max capture time ({self.max_capture_time}s)')
598
595
  except Exception as e:
599
596
  logger.exception(f'Something went poorly {url} - {e}')
600
597
  result = {'error': f'Something went poorly {url} - {e}'}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lacuscore
3
- Version: 1.9.4
3
+ Version: 1.9.5
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
@@ -28,9 +28,9 @@ Requires-Dist: Sphinx (>=7.2,<8.0) ; (python_version >= "3.9") and (extra == "do
28
28
  Requires-Dist: async-timeout (>=4.0.3,<5.0.0) ; python_version < "3.11"
29
29
  Requires-Dist: defang (>=0.5.3,<0.6.0)
30
30
  Requires-Dist: dnspython (>=2.6.1,<3.0.0)
31
- Requires-Dist: playwrightcapture[recaptcha] (>=1.24.10,<2.0.0)
31
+ Requires-Dist: playwrightcapture[recaptcha] (>=1.24.11,<2.0.0)
32
32
  Requires-Dist: redis[hiredis] (>=5.0.4,<6.0.0)
33
- Requires-Dist: requests (>=2.32.1,<3.0.0)
33
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
34
34
  Requires-Dist: ua-parser (>=0.18.0,<0.19.0)
35
35
  Project-URL: Documentation, https://lacuscore.readthedocs.io/en/latest/
36
36
  Project-URL: Repository, https://github.com/ail-project/LacusCore
@@ -1,10 +1,10 @@
1
1
  lacuscore/__init__.py,sha256=hM4lKoPNybDCUMWdXTVVI1gRk_riLvRZ7IwFbamZLzE,341
2
2
  lacuscore/helpers.py,sha256=lULN7HhY-4a4HG-ybIt4jO3wEGTxkm_jKNqsGpNZo4Y,2711
3
3
  lacuscore/lacus_monitoring.py,sha256=UOfE_1-_rhVeKJXQ_m9XxYkr7VwyQnA6iK-x_tcXJfo,2775
4
- lacuscore/lacuscore.py,sha256=zi6oOcwmZ0yENIfJy55baeGXw3Js4lg5fmQz0YFRNJk,43030
4
+ lacuscore/lacuscore.py,sha256=6YQ6ORW9yJP-cEf7zmPC196zVJI2-nI3Sq9M0VoDxWQ,42843
5
5
  lacuscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  lacuscore/task_logger.py,sha256=8WbdJdKnGeFCxt9gtCNLI9vAQQZbsy2I5PRQpHP7XFU,1916
7
- lacuscore-1.9.4.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
8
- lacuscore-1.9.4.dist-info/METADATA,sha256=Lr1wGWp4zfC19UwS51sjTxznPywLBZ7-0e9rAF88cYs,2629
9
- lacuscore-1.9.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
- lacuscore-1.9.4.dist-info/RECORD,,
7
+ lacuscore-1.9.5.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
8
+ lacuscore-1.9.5.dist-info/METADATA,sha256=aNJ8gH24KtwIpcyHRkCsfz-kfcC8dLQfVkadqY7knko,2629
9
+ lacuscore-1.9.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
+ lacuscore-1.9.5.dist-info/RECORD,,