This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: exposes additional worker configuration parameters #268
Draft
cofin
wants to merge
2
commits into
topsport-com-au:main
Choose a base branch
from
cofin:worker-attributes
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.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
from starlite_saqlalchemy.service import Service | ||
|
||
__all__ = [ | ||
"CronJob", | ||
"JobConfig", | ||
"Queue", | ||
"Worker", | ||
|
@@ -138,25 +139,48 @@ class JobConfig: | |
""" | ||
|
||
|
||
class CronJob(saq.CronJob): | ||
"""Cron Job.""" | ||
Comment on lines
+142
to
+143
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. is this for anything? 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. It's main purpose now is for for convenience. (i.e. you can import all of the classes from worker instead of having to import from |
||
|
||
|
||
default_job_config_dict = utils.dataclass_as_dict_shallow(JobConfig(), exclude_none=True) | ||
|
||
|
||
def create_worker_instance( | ||
functions: Collection[Callable[..., Any] | tuple[str, Callable]], | ||
cron_jobs: Collection[saq.CronJob] = (), | ||
concurrency: int | None = None, | ||
startup: Callable[[dict[str, Any]], Awaitable[Any]] | None = None, | ||
shutdown: Callable[[dict[str, Any]], Awaitable[Any]] | None = None, | ||
before_process: Callable[[dict[str, Any]], Awaitable[Any]] | None = None, | ||
after_process: Callable[[dict[str, Any]], Awaitable[Any]] | None = None, | ||
) -> Worker: | ||
""" | ||
"""Create a worker instance. | ||
|
||
Args: | ||
functions: Functions to be called via the async workers. | ||
cron_jobs: Cron configuration to schedule at startup. | ||
concurrency: The number of jobs allowed to execute simultaneously per worker. | ||
startup: Async function called on worker startup. | ||
shutdown: Async function called on worker shutdown. | ||
before_process: Async function called before a job processes. | ||
after_process: Async function called after a job processes. | ||
|
||
Returns: | ||
The worker instance, instantiated with `functions`. | ||
""" | ||
return Worker(queue, functions, before_process=before_process, after_process=after_process) | ||
if concurrency is None: | ||
concurrency = settings.worker.CONCURRENCY | ||
return Worker( | ||
queue, | ||
functions=functions, | ||
cron_jobs=cron_jobs, | ||
startup=startup, | ||
concurrency=concurrency, | ||
shutdown=shutdown, | ||
before_process=before_process, | ||
after_process=after_process, | ||
) | ||
|
||
|
||
async def make_service_callback( | ||
|
Submodule starlite-saqlalchemy
added at
2bf692
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.
Is this for this?
sqlalchemy/sqlalchemy#7714
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.
It is, I didn't think to look for an open issue on this.
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.
I wonder if the issue is arm64 in general, or just M1?
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.
I believe this is going to be an M1/OSX only specific issue. I'd bet that the x86 OSX laptops probably do not have this issue. Is there a way to specify architecture as well?
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.
I don't know - we are considering moving our workloads onto https://aws.amazon.com/ec2/graviton/ - so I might just spin one up and see if it gets the same treatment as m1