-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#64) Support tasks retry & propagate raised exception #65
Open
imranariffin
wants to merge
6
commits into
main
Choose a base branch
from
64/support-retry-on-tasks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4d4c0c0
(#64) Support tasks retry & propagate raised exception
imranariffin af06338
Rename constants.py to config.py
imranariffin ce851d7
Split file into config.py & constants.py
imranariffin a4612ce
Fixup prev
imranariffin a21c251
Remove unused attribute from AsyncResult
imranariffin 5bd0afa
Avoid retrying forever
imranariffin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,47 @@ | ||
""" | ||
Module to define and store all configuration values used across the library. | ||
|
||
The public object from this module is `Config`. This object wraps | ||
all the configuration values, which include: | ||
- Variables | ||
- Environment variables | ||
""" | ||
|
||
import logging | ||
from os import environ | ||
|
||
from .interfaces import SerializationType | ||
|
||
_REDIS_URL = "redis://127.0.0.1:6379" | ||
|
||
|
||
class Config: | ||
""" | ||
Provide configuration values. | ||
|
||
These include: | ||
- Variables | ||
- Environment variables | ||
""" | ||
|
||
@staticmethod | ||
def serialization_type() -> SerializationType: | ||
"""Return the serialization type as provided via env var AIOTASKQ_SERIALIZATION.""" | ||
s: str = environ.get("AIOTASKQ_SERIALIZATION", SerializationType.DEFAULT.value) | ||
return SerializationType[s.upper()] | ||
|
||
@staticmethod | ||
def log_level() -> int: | ||
"""Return the log level as provided via env var LOG_LEVEL.""" | ||
level: int = int(environ.get("AIOTASKQ_LOG_LEVEL", logging.DEBUG)) | ||
return level | ||
|
||
@staticmethod | ||
def broker_url() -> str: | ||
""" | ||
Return the broker url as provided via env var BROKER_URL. | ||
|
||
Defaults to "redis://127.0.0.1:6379". | ||
""" | ||
broker_url: str = environ.get("BROKER_URL", _REDIS_URL) | ||
return broker_url |
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,30 @@ | ||
"""Module to define and store all constants used across the library.""" | ||
""" | ||
Module to define and store all constants used across the library. | ||
|
||
REDIS_URL = "redis://127.0.0.1:6379" | ||
TASKS_CHANNEL = "channel:tasks" | ||
RESULTS_CHANNEL_TEMPLATE = "channel:results:{task_id}" | ||
The public object from this module is `Constants`. This object wraps | ||
all the constants, which include: | ||
- Static methods that return constant values | ||
""" | ||
|
||
|
||
_TASKS_CHANNEL = "channel:tasks" | ||
_RESULTS_CHANNEL_TEMPLATE = "channel:results:{task_id}" | ||
|
||
|
||
class Constants: | ||
""" | ||
Provide all the constants. | ||
|
||
These include: | ||
- Static methods that return constant values | ||
""" | ||
|
||
@staticmethod | ||
def tasks_channel() -> str: | ||
"""Return the channel name used for transporting task requests on the broker.""" | ||
return _TASKS_CHANNEL | ||
|
||
@staticmethod | ||
def results_channel_template() -> str: | ||
"""Return the template chnnale name used for transporting task results on the broker.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe better to split this into two files, one for config & one for constants There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm maybe that's a good idea |
||
return _RESULTS_CHANNEL_TEMPLATE |
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably rename this to
config.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed