-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove top lvl race condition (#112)
* Make RESONATE GROUP configurable through env variables * Simplify imports * pin rye version * Expose execute here option * Remove race condition * Change API to not use recv * Allow to import ctx from top lvl * fix subscribe typo * Order helper methods on scheduler * Fix typo error and pass pid to start methods * rename queue to delay queue * rename onboard to forkorjoin * fix typo loopback
- Loading branch information
1 parent
95a3be3
commit 282c84b
Showing
28 changed files
with
439 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
from __future__ import annotations | ||
|
||
from . import random | ||
from resonate.context import Context | ||
from resonate.dataclasses import DurablePromise | ||
from resonate.handle import Handle | ||
from resonate.promise import Promise | ||
from resonate.resonate import Resonate | ||
|
||
__all__ = ["random"] | ||
__all__ = ["Resonate", "Handle", "DurablePromise", "Promise", "Context"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from concurrent.futures import Future | ||
from dataclasses import dataclass, field | ||
from typing import Generic, TypeVar, final | ||
|
||
from typing_extensions import assert_never | ||
|
||
from resonate.result import Err, Ok, Result | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
@final | ||
@dataclass(frozen=True) | ||
class Handle(Generic[T]): | ||
id: str | ||
f: Future[T] = field(repr=False, default_factory=Future, init=False) | ||
|
||
def result(self, timeout: float | None = None) -> T: | ||
return self.f.result(timeout=timeout) | ||
|
||
def set_result(self, result: Result[T, Exception]) -> None: | ||
if isinstance(result, Ok): | ||
self.f.set_result(result.unwrap()) | ||
elif isinstance(result, Err): | ||
self.f.set_exception(result.err()) | ||
else: | ||
assert_never(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, final | ||
|
||
if TYPE_CHECKING: | ||
from resonate import retry_policy | ||
|
||
|
||
@final | ||
@dataclass | ||
class Options: | ||
def __init__( | ||
self, | ||
*, | ||
id: str | None = None, | ||
durable: bool = True, | ||
send_to: str | None = None, | ||
retry_policy: retry_policy.RetryPolicy | None = None, | ||
version: int = 1, | ||
) -> None: | ||
self.durable = durable | ||
self.id = id | ||
self.retry_policy = retry_policy | ||
self.send_to = send_to | ||
self.version = version | ||
id: str | None = None | ||
durable: bool = True | ||
send_to: str | None = None | ||
retry_policy: retry_policy.RetryPolicy | None = None | ||
version: int = 1 | ||
execute_here: bool = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import Generic, TypeVar, final | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
@final | ||
@dataclass(frozen=True) | ||
class Promise(Generic[T]): | ||
id: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.