Skip to content

Commit c88bfa9

Browse files
author
Sergio García Prado
committed
ISSUE #176
* Working on timeout attribute.
1 parent be24f25 commit c88bfa9

File tree

1 file changed

+7
-1
lines changed
  • packages/core/minos-microservice-saga/minos/saga/executions

1 file changed

+7
-1
lines changed

packages/core/minos-microservice-saga/minos/saga/executions/runners.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import logging
88
import warnings
9+
from asyncio import (
10+
wait_for,
11+
)
912
from functools import (
1013
reduce,
1114
)
@@ -96,6 +99,7 @@ async def run(
9699
pause_on_disk: bool = False,
97100
raise_on_error: bool = True,
98101
return_execution: bool = True,
102+
timeout: Optional[float] = 60.0,
99103
**kwargs,
100104
) -> Union[UUID, SagaExecution]:
101105
"""Perform a run of a ``Saga``.
@@ -114,6 +118,7 @@ async def run(
114118
but with ``Errored`` status.
115119
:param return_execution: If ``True`` the ``SagaExecution`` instance is returned. Otherwise, only the
116120
identifier (``UUID``) is returned.
121+
:param timeout: TODO
117122
:param kwargs: Additional named arguments.
118123
:return: This method does not return anything.
119124
"""
@@ -125,7 +130,7 @@ async def run(
125130
else:
126131
execution = await self._load(response)
127132

128-
return await self._run(
133+
future = self._run(
129134
execution,
130135
response=response,
131136
autocommit=autocommit,
@@ -134,6 +139,7 @@ async def run(
134139
return_execution=return_execution,
135140
**kwargs,
136141
)
142+
return await wait_for(future, timeout=timeout)
137143

138144
@staticmethod
139145
async def _create(definition: Saga, context: Optional[SagaContext], user: Optional[UUID]) -> SagaExecution:

0 commit comments

Comments
 (0)