async-lambda-unstable 0.5.3__tar.gz → 0.5.4__tar.gz

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.
Files changed (36) hide show
  1. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/PKG-INFO +1 -1
  2. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/__init__.py +2 -1
  3. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/controller.py +23 -4
  4. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/env.py +4 -0
  5. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda_unstable.egg-info/PKG-INFO +1 -1
  6. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/README.md +0 -0
  7. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/build_config.py +0 -0
  8. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/cli.py +0 -0
  9. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/client.py +0 -0
  10. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/config.py +0 -0
  11. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/defer.py +0 -0
  12. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/middleware.py +0 -0
  13. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/__init__.py +0 -0
  14. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/api_response.py +0 -0
  15. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/case_insensitive_dict.py +0 -0
  16. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/__init__.py +0 -0
  17. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/api_event.py +0 -0
  18. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/base_event.py +0 -0
  19. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/dynamodb_event.py +0 -0
  20. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/managed_sqs_batch_event.py +0 -0
  21. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/managed_sqs_event.py +0 -0
  22. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/scheduled_event.py +0 -0
  23. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/events/unmanaged_sqs_event.py +0 -0
  24. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/mock/mock_context.py +0 -0
  25. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/mock/mock_event.py +0 -0
  26. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/models/task.py +0 -0
  27. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/payload_encoder.py +0 -0
  28. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/py.typed +0 -0
  29. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda/util.py +0 -0
  30. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda_unstable.egg-info/SOURCES.txt +0 -0
  31. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda_unstable.egg-info/dependency_links.txt +0 -0
  32. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda_unstable.egg-info/entry_points.txt +0 -0
  33. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda_unstable.egg-info/requires.txt +0 -0
  34. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/async_lambda_unstable.egg-info/top_level.txt +0 -0
  35. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/pyproject.toml +0 -0
  36. {async-lambda-unstable-0.5.3 → async-lambda-unstable-0.5.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: async-lambda-unstable
3
- Version: 0.5.3
3
+ Version: 0.5.4
4
4
  Summary: A framework for creating AWS Lambda Async Workflows. - Unstable Branch
5
5
  Author-email: "Nuclei, Inc" <engineering@nuclei.ai>
6
6
  Description-Content-Type: text/markdown
@@ -2,6 +2,7 @@ from .config import config_set_name as config_set_name
2
2
  from .config import config_set_runtime as config_set_runtime
3
3
  from .config import config_set_s3_payload_retention as config_set_s3_payload_retention
4
4
  from .controller import AsyncLambdaController as AsyncLambdaController
5
+ from .controller import BatchInvokeException as BatchInvokeException
5
6
  from .defer import Defer as Defer
6
7
  from .env import disable_force_sync_mode as disable_force_sync_mode
7
8
  from .env import enable_force_sync_mode as enable_force_sync_mode
@@ -19,4 +20,4 @@ from .models.events.managed_sqs_event import ManagedSQSEvent as ManagedSQSEvent
19
20
  from .models.events.scheduled_event import ScheduledEvent as ScheduledEvent
20
21
  from .models.events.unmanaged_sqs_event import UnmanagedSQSEvent as UnmanagedSQSEvent
21
22
 
22
- __version__ = "0.5.3"
23
+ __version__ = "0.5.4"
@@ -1,6 +1,7 @@
1
1
  import functools
2
2
  import json
3
3
  import logging
4
+ import random
4
5
  import re
5
6
  import time
6
7
  from datetime import datetime, timezone
@@ -47,6 +48,14 @@ ScheduledEventT = TypeVar("ScheduledEventT", bound=ScheduledEvent)
47
48
  DynamoDBEventT = TypeVar("DynamoDBEventT", bound=DynamoDBEvent)
48
49
 
49
50
 
51
+ class BatchInvokeException(Exception):
52
+ failed_payloads: List[int]
53
+
54
+ def __init__(self, msg: str, failed_payloads: List[int]):
55
+ self.failed_payloads = failed_payloads
56
+ super().__init__(msg)
57
+
58
+
50
59
  class AsyncLambdaController:
51
60
  is_sub: bool
52
61
  lane_count: Optional[int] = None
@@ -69,7 +78,7 @@ class AsyncLambdaController:
69
78
  lane_count: Optional[int] = None,
70
79
  propagate_lane_assignment: Optional[bool] = None,
71
80
  middleware: Optional[List[MiddlewareRegistration]] = None,
72
- delete_s3_payloads: bool = True,
81
+ delete_s3_payloads: bool = False,
73
82
  controller_name: Optional[str] = None,
74
83
  ):
75
84
  self.tasks = dict()
@@ -551,7 +560,8 @@ class AsyncLambdaController:
551
560
  else:
552
561
  url = destination_task.get_managed_queue_url(lane=lane)
553
562
  failed_messages = []
554
- for _ in range(5):
563
+ batch_retry_count = env.get_batch_failure_retry_count() + 1
564
+ for i in range(batch_retry_count):
555
565
  response = get_sqs_client().send_message_batch(
556
566
  QueueUrl=url,
557
567
  Entries=entries,
@@ -560,13 +570,22 @@ class AsyncLambdaController:
560
570
  if len(failed_messages) == 0:
561
571
  return
562
572
  logger.warning(failed_messages)
563
- logger.warning(f"{len(failed_messages)} messages failed to send.")
573
+ logger.warning(f"{len(failed_messages)} messages failed to send. ")
564
574
  failed_message_ids = {message["Id"] for message in failed_messages}
565
575
  entries = [
566
576
  entry for entry in entries if entry["Id"] in failed_message_ids
567
577
  ]
578
+ if i < batch_retry_count:
579
+ send_delay = 0.5 + random.random()
580
+ logger.info(
581
+ f"Waiting {send_delay:.3f} before attempting batch failures again."
582
+ )
583
+ time.sleep(send_delay)
568
584
  logger.error(failed_messages)
569
- raise Exception(f"Failed to send {len(failed_messages)} messages.")
585
+ raise BatchInvokeException(
586
+ f"Failed to send {len(failed_messages)} messages.",
587
+ failed_payloads=[int(entry["Id"].split("_")[-1]) for entry in entries],
588
+ )
570
589
 
571
590
  def new_payload(
572
591
  self,
@@ -79,3 +79,7 @@ def disable_force_sync_mode():
79
79
 
80
80
  def get_force_sync_mode() -> bool:
81
81
  return bool(os.environ.get("ASYNC_LAMBDA_FORCE_SYNC", ""))
82
+
83
+
84
+ def get_batch_failure_retry_count() -> int:
85
+ return int(os.environ.get("ASYNC_LAMBDA_BATCH_FAILURE_RETRY_COUNT", 20))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: async-lambda-unstable
3
- Version: 0.5.3
3
+ Version: 0.5.4
4
4
  Summary: A framework for creating AWS Lambda Async Workflows. - Unstable Branch
5
5
  Author-email: "Nuclei, Inc" <engineering@nuclei.ai>
6
6
  Description-Content-Type: text/markdown