durabletask 1.4.0.dev33__py3-none-any.whl → 1.4.0.dev34__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.
durabletask/task.py CHANGED
@@ -4,6 +4,7 @@
4
4
  # See https://peps.python.org/pep-0563/
5
5
  from __future__ import annotations
6
6
 
7
+ import logging
7
8
  import math
8
9
  from abc import ABC, abstractmethod
9
10
  from datetime import datetime, timedelta, timezone
@@ -279,6 +280,51 @@ class OrchestrationContext(ABC):
279
280
  def _exit_critical_section(self) -> None:
280
281
  pass
281
282
 
283
+ def create_replay_safe_logger(self, logger: logging.Logger) -> ReplaySafeLogger:
284
+ """Create a replay-safe logger that suppresses log messages during orchestration replay.
285
+
286
+ The returned logger wraps the provided logger and only emits log messages when
287
+ the orchestrator is not replaying. This prevents duplicate log messages from
288
+ appearing as a side effect of orchestration replay.
289
+
290
+ Parameters
291
+ ----------
292
+ logger : logging.Logger
293
+ The underlying logger to wrap.
294
+
295
+ Returns
296
+ -------
297
+ ReplaySafeLogger
298
+ A logger that only emits log messages when the orchestrator is not replaying.
299
+ """
300
+ return ReplaySafeLogger(logger, lambda: self.is_replaying)
301
+
302
+
303
+ class ReplaySafeLogger(logging.LoggerAdapter):
304
+ """A logger adapter that suppresses log messages during orchestration replay.
305
+
306
+ This class extends :class:`logging.LoggerAdapter` and only emits log
307
+ messages when the orchestrator is *not* replaying. Use this to avoid
308
+ duplicate log entries that would otherwise appear every time the
309
+ orchestrator replays its history.
310
+
311
+ Obtain an instance by calling :meth:`OrchestrationContext.create_replay_safe_logger`.
312
+ """
313
+
314
+ def __init__(self, logger: logging.Logger, is_replaying: Callable[[], bool]) -> None:
315
+ super().__init__(logger, {})
316
+ self._is_replaying = is_replaying
317
+
318
+ def isEnabledFor(self, level: int) -> bool:
319
+ """Return whether logging is enabled for the given level.
320
+
321
+ Returns ``False`` while the orchestrator is replaying so that callers
322
+ can skip expensive message formatting during replay.
323
+ """
324
+ if self._is_replaying():
325
+ return False
326
+ return self.logger.isEnabledFor(level)
327
+
282
328
 
283
329
  class FailureDetails:
284
330
  def __init__(self, message: str, error_type: str, stack_trace: Optional[str]):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: durabletask
3
- Version: 1.4.0.dev33
3
+ Version: 1.4.0.dev34
4
4
  Summary: A Durable Task Client SDK for Python
5
5
  License: MIT License
6
6
 
@@ -3,7 +3,7 @@ durabletask/client.py,sha256=PUOTYi0Kw7JoREbz-W8Gw5tjN_VCZxBLMqLq0T97unQ,40086
3
3
  durabletask/grpc_options.py,sha256=k1xXnKzK5b_86wibuh7Ype396A-Gs6P4nbHBaUSpE9U,4174
4
4
  durabletask/history.py,sha256=VhrWb5eFr9TZSaazpotdMzKt2quwLuJVRk9j39WbTPs,18680
5
5
  durabletask/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- durabletask/task.py,sha256=QS7RPUaWhb4Xq5hi7nnueooJqQSDO6ipEoiAiSVkAIs,24009
6
+ durabletask/task.py,sha256=FNKLQjlIRIwyPqGHvY1gua9uaoDEPAmkHG0PYpHG_1I,25807
7
7
  durabletask/worker.py,sha256=ZNx_85fGjgUkjJK_dEI2AZRB4qM3XMV6hgPlc3PPdFk,134691
8
8
  durabletask/entities/__init__.py,sha256=DbNd5riqWZaj3tG6gN82O8Q6wTmFpe6QaH0pQgDSPHs,721
9
9
  durabletask/entities/durable_entity.py,sha256=LQPWnUlRsHiFVRoTdpeSK--eXtjf2UGbVQwEEKf7QwI,3318
@@ -35,8 +35,8 @@ durabletask/payload/helpers.py,sha256=RYG5MEVAqHjm4zfFHs3Td91FVQHUoCcb5hbEJ4sYj5
35
35
  durabletask/payload/store.py,sha256=3qJMvKxRUkr6ScWUzxpKAVgzuhFLywRW8a2_5OOmNk4,3000
36
36
  durabletask/testing/__init__.py,sha256=rXbcSFtzuaRAbDNX-HmdgbxLTegvKJ1FRjZfSOIAMgA,323
37
37
  durabletask/testing/in_memory_backend.py,sha256=mF0zCA3GMLUd0vqa7CvkgBhYXH4VCsqHReIWuw72wvA,82530
38
- durabletask-1.4.0.dev33.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
39
- durabletask-1.4.0.dev33.dist-info/METADATA,sha256=j-H4_LOnSpIKW4dCQEfyA7cgv2ZG-LaIaCmmvv-aQ0M,4404
40
- durabletask-1.4.0.dev33.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
41
- durabletask-1.4.0.dev33.dist-info/top_level.txt,sha256=EBVyuKWnjOwq8bJI1Uvb9U3c4fzQxACWj9p83he6fik,12
42
- durabletask-1.4.0.dev33.dist-info/RECORD,,
38
+ durabletask-1.4.0.dev34.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
39
+ durabletask-1.4.0.dev34.dist-info/METADATA,sha256=1dUysdof6iFKMdY1_D0PS9UKNYkADPNUO45fRTXQnok,4404
40
+ durabletask-1.4.0.dev34.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
41
+ durabletask-1.4.0.dev34.dist-info/top_level.txt,sha256=EBVyuKWnjOwq8bJI1Uvb9U3c4fzQxACWj9p83he6fik,12
42
+ durabletask-1.4.0.dev34.dist-info/RECORD,,