durabletask 1.4.0.dev32__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.dev32
3
+ Version: 1.4.0.dev34
4
4
  Summary: A Durable Task Client SDK for Python
5
5
  License: MIT License
6
6
 
@@ -46,38 +46,48 @@ Dynamic: license-file
46
46
 
47
47
  # Durable Task SDK for Python
48
48
 
49
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
50
- [![Build Validation](https://github.com/microsoft/durabletask-python/actions/workflows/pr-validation.yml/badge.svg)](https://github.com/microsoft/durabletask-python/actions/workflows/pr-validation.yml)
49
+ [![License:
50
+ MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
51
+ [![Build
52
+ Validation](https://github.com/microsoft/durabletask-python/actions/workflows/pr-validation.yml/badge.svg)](https://github.com/microsoft/durabletask-python/actions/workflows/pr-validation.yml)
51
53
  [![PyPI version](https://badge.fury.io/py/durabletask.svg)](https://badge.fury.io/py/durabletask)
52
54
 
53
- This repo contains a Python SDK for use with the [Azure Durable Task Scheduler](https://github.com/Azure/Durable-Task-Scheduler). With this SDK, you can define, schedule, and manage durable orchestrations using ordinary Python code.
55
+ This repo contains a Python SDK for use with the [Azure Durable Task
56
+ Scheduler](https://github.com/Azure/Durable-Task-Scheduler). With this SDK, you can define,
57
+ schedule, and manage durable orchestrations using ordinary Python code.
54
58
 
55
- > Note that this SDK is **not** currently compatible with [Azure Durable Functions](https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-overview). If you are looking for a Python SDK for Azure Durable Functions, please see [this repo](https://github.com/Azure/azure-functions-durable-python).
59
+ > Note that this SDK is **not** currently compatible with [Azure Durable
60
+ Functions](https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-overview). If
61
+ you are looking for a Python SDK for Azure Durable Functions, please see [this
62
+ repo](https://github.com/Azure/azure-functions-durable-python).
63
+
64
+ ## References
56
65
 
57
- # References
58
66
  - [Supported Patterns](./docs/supported-patterns.md)
59
67
  - [Available Features](./docs/features.md)
60
68
  - [Getting Started](./docs/getting-started.md)
61
- - [Development Guide](./docs/development.md)
69
+ - [Development Guide](./docs/development.md)
62
70
  - [Contributing Guide](./CONTRIBUTING.md)
63
71
 
64
72
  ## Optional Features
65
73
 
66
74
  ### Large Payload Externalization
67
75
 
68
- Install the `azure-blob-payloads` extra to automatically offload
69
- oversized orchestration payloads to Azure Blob Storage:
76
+ Install the `azure-blob-payloads` extra to automatically offload oversized orchestration payloads to
77
+ Azure Blob Storage:
70
78
 
71
79
  ```bash
72
80
  pip install durabletask[azure-blob-payloads]
73
81
  ```
74
82
 
75
- See the [feature documentation](./docs/features.md#large-payload-externalization)
76
- and the [example](./examples/large_payload/) for usage details.
83
+ See the [feature documentation](./docs/features.md#large-payload-externalization) and the
84
+ [example](./examples/large_payload/) for usage details.
77
85
 
78
86
  ## Trademarks
79
- This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
80
- trademarks or logos is subject to and must follow
81
- [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
82
- Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
83
- Any use of third-party trademarks or logos are subject to those third-party's policies.
87
+
88
+ This project may contain trademarks or logos for projects, products, or services. Authorized use of
89
+ Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand
90
+ Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
91
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion
92
+ or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those
93
+ third-party's policies.
@@ -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.dev32.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
39
- durabletask-1.4.0.dev32.dist-info/METADATA,sha256=6jrrQkmgSTCTRRdoeoFUUKpP0OUVNjB4inn5V4Ua9-M,4404
40
- durabletask-1.4.0.dev32.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
41
- durabletask-1.4.0.dev32.dist-info/top_level.txt,sha256=EBVyuKWnjOwq8bJI1Uvb9U3c4fzQxACWj9p83he6fik,12
42
- durabletask-1.4.0.dev32.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,,