scrapely-python 0.1.34__py3-none-any.whl → 0.1.35__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.
- scrapely/__init__.py +1 -1
- scrapely/actor.py +44 -5
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/METADATA +1 -1
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/RECORD +9 -9
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/WHEEL +0 -0
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/licenses/LICENSE +0 -0
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/licenses/LICENSE-APACHE +0 -0
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/licenses/NOTICE +0 -0
- {scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/top_level.txt +0 -0
scrapely/__init__.py
CHANGED
scrapely/actor.py
CHANGED
|
@@ -349,6 +349,10 @@ class Actor(metaclass=_ActorMeta):
|
|
|
349
349
|
_cached_input: Optional[Dict[str, Any]] = None
|
|
350
350
|
_exit_code: int = 0
|
|
351
351
|
_status_message: Optional[str] = None
|
|
352
|
+
# Set by fail() for the rest of the lifecycle: (exit code, status message).
|
|
353
|
+
# A later exit() keeps them, so `fail()` followed by the usual `exit()` in a
|
|
354
|
+
# `finally:` block still ends the run as FAILED (it used to exit with 0).
|
|
355
|
+
_failure: Optional[Tuple[int, Optional[str]]] = None
|
|
352
356
|
_charging_manager: Optional[ChargingManager] = None
|
|
353
357
|
_use_state_stores: set = set()
|
|
354
358
|
# Lifecycle bookkeeping set in init() / cleared in _shutdown().
|
|
@@ -392,9 +396,11 @@ class Actor(metaclass=_ActorMeta):
|
|
|
392
396
|
elif exc_type is not None:
|
|
393
397
|
cls._exit_code = 1
|
|
394
398
|
logger.error(f'Actor failed: {exc_val}')
|
|
399
|
+
elif cls._failure is not None:
|
|
400
|
+
cls._exit_code = cls._failure[0] # fail(exit=False) earlier: the run stays failed
|
|
395
401
|
else:
|
|
396
402
|
cls._exit_code = self._instance_exit_code
|
|
397
|
-
if self._instance_status_message:
|
|
403
|
+
if self._instance_status_message and cls._failure is None:
|
|
398
404
|
cls._status_message = self._instance_status_message
|
|
399
405
|
await cls._persist_terminal_status_message(self._instance_status_message)
|
|
400
406
|
await cls._shutdown(timeout_secs=int(self._cleanup_timeout.total_seconds()))
|
|
@@ -410,6 +416,7 @@ class Actor(metaclass=_ActorMeta):
|
|
|
410
416
|
cls._main_loop = asyncio.get_running_loop() # for debug_capture_sync from worker threads
|
|
411
417
|
if cls._initialized:
|
|
412
418
|
return
|
|
419
|
+
cls._failure = None # a new lifecycle starts unfailed
|
|
413
420
|
|
|
414
421
|
if options is None or options.configure_logging:
|
|
415
422
|
_lazy('_configure_logging')()
|
|
@@ -701,13 +708,33 @@ class Actor(metaclass=_ActorMeta):
|
|
|
701
708
|
if exit_code is not None:
|
|
702
709
|
opts.exit_code = exit_code
|
|
703
710
|
|
|
704
|
-
if
|
|
711
|
+
if cls._failure is not None:
|
|
712
|
+
# Actor.fail() already ran: the run stays failed. Keep its exit code and
|
|
713
|
+
# status message; a later exit() (e.g. in a `finally:` block) only
|
|
714
|
+
# finishes the shutdown and exits with the failure's code.
|
|
715
|
+
if opts.status_message:
|
|
716
|
+
logger.info(f'[Scrapely] {opts.status_message}')
|
|
717
|
+
logger.info(
|
|
718
|
+
'[Scrapely] Actor.exit() after Actor.fail(): the run stays failed (exit code %s).',
|
|
719
|
+
cls._failure[0],
|
|
720
|
+
)
|
|
721
|
+
opts = ExitOptions(**{**opts.__dict__})
|
|
722
|
+
opts.exit_code, opts.status_message = cls._failure
|
|
723
|
+
await cls._exit_with(opts, persist_message=False)
|
|
724
|
+
return
|
|
725
|
+
|
|
726
|
+
await cls._exit_with(opts)
|
|
727
|
+
|
|
728
|
+
@classmethod
|
|
729
|
+
async def _exit_with(cls, opts: ExitOptions, persist_message: bool = True) -> None:
|
|
730
|
+
if opts.status_message and persist_message:
|
|
705
731
|
logger.info(f'[Scrapely] {opts.status_message}')
|
|
706
732
|
|
|
707
733
|
cls._exit_code = opts.exit_code
|
|
708
734
|
cls._status_message = opts.status_message
|
|
709
735
|
|
|
710
|
-
|
|
736
|
+
if persist_message:
|
|
737
|
+
await cls._persist_terminal_status_message(opts.status_message)
|
|
711
738
|
await cls._shutdown(timeout_secs=opts.timeout_secs)
|
|
712
739
|
|
|
713
740
|
if opts.exit:
|
|
@@ -736,7 +763,7 @@ class Actor(metaclass=_ActorMeta):
|
|
|
736
763
|
if isinstance(message_or_options, str):
|
|
737
764
|
opts = ExitOptions(exit_code=1, status_message=message_or_options)
|
|
738
765
|
else:
|
|
739
|
-
# Options-object form:
|
|
766
|
+
# Options-object form: a non-zero exit_code in the object wins over
|
|
740
767
|
# the fail() default of 1 (JS SDK semantics). Build the dict first —
|
|
741
768
|
# passing it alongside exit_code=1 as kwargs raises
|
|
742
769
|
# "got multiple values for keyword argument 'exit_code'".
|
|
@@ -751,12 +778,24 @@ class Actor(metaclass=_ActorMeta):
|
|
|
751
778
|
opts.status_message = status_message
|
|
752
779
|
if exit_code is not None:
|
|
753
780
|
opts.exit_code = exit_code
|
|
781
|
+
elif not opts.exit_code:
|
|
782
|
+
# ExitOptions always carries exit_code (default 0), so 0 from an options
|
|
783
|
+
# object means "not set": a failed run must not exit with 0. Only an
|
|
784
|
+
# explicit exit_code=0 keyword keeps 0.
|
|
785
|
+
opts.exit_code = 1
|
|
754
786
|
|
|
755
787
|
logger.error(
|
|
756
788
|
f'[Scrapely] Actor failed: {opts.status_message or "Unknown error"}',
|
|
757
789
|
exc_info=exception,
|
|
758
790
|
)
|
|
759
|
-
|
|
791
|
+
if cls._failure is not None:
|
|
792
|
+
# Failed already: the first failure's code and message stay.
|
|
793
|
+
opts = ExitOptions(**{**opts.__dict__})
|
|
794
|
+
opts.exit_code, opts.status_message = cls._failure
|
|
795
|
+
await cls._exit_with(opts, persist_message=False)
|
|
796
|
+
return
|
|
797
|
+
cls._failure = (opts.exit_code, opts.status_message)
|
|
798
|
+
await cls._exit_with(opts)
|
|
760
799
|
|
|
761
800
|
@classmethod
|
|
762
801
|
def is_at_home(cls) -> bool:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
scrapely/__init__.py,sha256=
|
|
1
|
+
scrapely/__init__.py,sha256=SmvxiukorN0XL3Y1vuRgnzxUfSfHd9waw2EHX_-06XU,9668
|
|
2
2
|
scrapely/_browser_locations.py,sha256=8QVVnkms2bDn3_LDYgYDR59MvFx8757l_JYnZ7xb3oI,145269
|
|
3
|
-
scrapely/actor.py,sha256=
|
|
3
|
+
scrapely/actor.py,sha256=z-kL24Y6m98v6lKLOxGYCnFmhVhaHJ6c0uOdYZW_4ak,93514
|
|
4
4
|
scrapely/browser_configuration.py,sha256=jAZapNSHLFW05B96df4wNBtcyiiU9DA3ml0yTL1FwfA,5770
|
|
5
5
|
scrapely/cdp_retry.py,sha256=hdTJEAIKhApM7IOk1DrQEl8NoflSJSmqd4RbNJ2IsgI,8540
|
|
6
6
|
scrapely/charging.py,sha256=osi2Ys99IyIJwFj0eRtV_RshokPs4mA2CE7oftNbN58,95559
|
|
@@ -55,10 +55,10 @@ scrapely/storage/_file_system/_key_value_store_client.py,sha256=1C22qY-RWlARzMyW
|
|
|
55
55
|
scrapely/storage/_file_system/_storage_client.py,sha256=QHa3IULEb6AmgRFwpBqHD2OUTmtA_gl3lId-j6QdSFo,2027
|
|
56
56
|
scrapely/storage_clients/__init__.py,sha256=q2pC-Rwe-BfHl018OyN_P0EDSx4-hNdxbk3pOCLLd4U,618
|
|
57
57
|
scrapely/storages/__init__.py,sha256=kDNtd9VodjdHd4u7GzruJo0aB2HeiBN2_-HrkeqjmFg,139
|
|
58
|
-
scrapely_python-0.1.
|
|
59
|
-
scrapely_python-0.1.
|
|
60
|
-
scrapely_python-0.1.
|
|
61
|
-
scrapely_python-0.1.
|
|
62
|
-
scrapely_python-0.1.
|
|
63
|
-
scrapely_python-0.1.
|
|
64
|
-
scrapely_python-0.1.
|
|
58
|
+
scrapely_python-0.1.35.dist-info/licenses/LICENSE,sha256=pQGY0XwjIYh-a2HfawxHq1en53bXkFkDj2Q70jKWHr4,1088
|
|
59
|
+
scrapely_python-0.1.35.dist-info/licenses/LICENSE-APACHE,sha256=N8m0FzMq8i4UbTgXZvKEZJSD-27OF8pWZYS_atz4kTU,11355
|
|
60
|
+
scrapely_python-0.1.35.dist-info/licenses/NOTICE,sha256=1ltrzKk2ez7x2BPNpXeyvOlTty5AfABYDBlwNilpORk,788
|
|
61
|
+
scrapely_python-0.1.35.dist-info/METADATA,sha256=TxvBCz5CkTKVznM0IpAU7LGEpOYNyptkKi1DzSNeKWQ,3582
|
|
62
|
+
scrapely_python-0.1.35.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
63
|
+
scrapely_python-0.1.35.dist-info/top_level.txt,sha256=T4B9UMrs4q99QSAFyD1zdXhl40KnLhBKqrDkPhOTsmY,9
|
|
64
|
+
scrapely_python-0.1.35.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{scrapely_python-0.1.34.dist-info → scrapely_python-0.1.35.dist-info}/licenses/LICENSE-APACHE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|