-
Couldn't load subscription status.
- Fork 32
🐛 Use Celery prefork pool for CPU-bound tasks
#8500
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
Merged
giancarloromeo
merged 78 commits into
ITISFoundation:master
from
giancarloromeo:is8496/use-prefork-pool-for-cpu-bound-celery-tasks
Oct 17, 2025
Merged
Changes from 13 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
fefdae2
prefork experiments
giancarloromeo 3ebb954
fix shutdown
giancarloromeo 9fc1e3d
Merge remote-tracking branch 'upstream/master' into is8496/use-prefor…
giancarloromeo 97e50d4
remove logs
giancarloromeo 29083b9
fix typecheck
giancarloromeo b3636fb
typecheck
giancarloromeo 27f4925
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo 76e886f
add settings
giancarloromeo fe05e66
unify worker setup
giancarloromeo e9371cb
Merge branch 'is8496/use-prefork-pool-for-cpu-bound-celery-tasks' of …
giancarloromeo 33d23bc
remove log
giancarloromeo 4ab42d8
remove unused
giancarloromeo c8e957b
fix api-server
giancarloromeo 1a8d135
update docker-compose
giancarloromeo 959fa79
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo d624966
fix test
giancarloromeo c97c75e
fix test
giancarloromeo d660041
fix test
giancarloromeo c4d33c4
fix test
giancarloromeo 012ea99
fix test
giancarloromeo fb1ac05
fix
giancarloromeo e6d01f3
fix tests
giancarloromeo 08e6c1a
fix tests
giancarloromeo 4f839b8
fix tests
giancarloromeo 1a86d71
typecheck
giancarloromeo ec1c828
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo fb4a847
fix tests
giancarloromeo 54ee4ca
Merge branch 'is8496/use-prefork-pool-for-cpu-bound-celery-tasks' of …
giancarloromeo d8c148b
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo da302cb
update description
giancarloromeo d1e342e
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo d5aa656
execute only once init in prefork
giancarloromeo 88ad319
refactoring
giancarloromeo ca12f4b
fix import
giancarloromeo 377d334
typecheck
giancarloromeo 3e218cd
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo d766256
use new signal handlers
giancarloromeo ade0d43
update name
giancarloromeo 41ad946
fix signals
giancarloromeo 1d8bb47
fix signals
giancarloromeo aaf0f12
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo db5d2d8
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo ce67003
Merge remote-tracking branch 'upstream/master' into is8496/use-prefor…
giancarloromeo f20badd
add rabbit
giancarloromeo 056954c
fix service selection
giancarloromeo c95d706
fix test
giancarloromeo 4ea087e
set worker mode
giancarloromeo 935478f
set worker mode
giancarloromeo 83fb4fe
fix
giancarloromeo 80dfc30
add redis
giancarloromeo 927fa7b
fix
giancarloromeo 901df8c
fix pool name
giancarloromeo 2409bd3
use wprker app settings
giancarloromeo 47fb61c
try
giancarloromeo 91a3f82
set pool
giancarloromeo b31d2f0
fix
giancarloromeo 6908e7e
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo d0c0085
mock celery app
giancarloromeo bb25608
Merge branch 'is8496/use-prefork-pool-for-cpu-bound-celery-tasks' of …
giancarloromeo c718176
fix
giancarloromeo 8f93ed4
fix mocks
giancarloromeo 02ae9da
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo daf3447
add startup timeout
giancarloromeo 4d04b63
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo 5518f24
Merge remote-tracking branch 'upstream/master' into is8496/use-prefor…
giancarloromeo 6713d4d
Merge branch 'is8496/use-prefork-pool-for-cpu-bound-celery-tasks' of …
giancarloromeo 20b56de
verbose storage
giancarloromeo bea45b4
restore
giancarloromeo 5970ecb
force shutdown
giancarloromeo cab7a6a
update
giancarloromeo 18ce2c7
try
giancarloromeo 2ceee86
revert
giancarloromeo f8a575b
fix test
giancarloromeo 5dcda9c
Merge remote-tracking branch 'upstream/master' into is8496/use-prefor…
giancarloromeo ce82a27
fix storage
giancarloromeo 945e0e5
fix api server
giancarloromeo c0cdaa2
fix api server tests
giancarloromeo 436e6dc
Merge branch 'master' into is8496/use-prefork-pool-for-cpu-bound-cele…
giancarloromeo 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
Empty file.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Empty file.
60 changes: 60 additions & 0 deletions
60
services/storage/src/simcore_service_storage/modules/celery/worker/main.py
This file contains hidden or 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,60 @@ | ||
| from celery.signals import ( # type: ignore[import-untyped] | ||
| worker_init, | ||
| worker_process_init, | ||
| worker_process_shutdown, | ||
| worker_shutdown, | ||
| ) | ||
| from celery_library.common import create_app as create_celery_app | ||
| from celery_library.signals import ( | ||
| on_worker_init, | ||
| on_worker_shutdown, | ||
| ) | ||
| from celery_library.utils import get_app_server, set_app_server | ||
| from servicelib.fastapi.celery.app_server import FastAPIAppServer | ||
| from servicelib.logging_utils import setup_loggers | ||
| from servicelib.tracing import TracingConfig | ||
|
|
||
| from ....api._worker_tasks.tasks import setup_worker_tasks | ||
| from ....core.application import create_app | ||
| from ....core.settings import ApplicationSettings | ||
|
|
||
| _settings = ApplicationSettings.create_from_envs() | ||
| _tracing_config = TracingConfig.create( | ||
| tracing_settings=_settings.STORAGE_TRACING, | ||
| service_name="storage-celery-worker", | ||
| ) | ||
|
|
||
|
|
||
| def get_app(): | ||
| setup_loggers( | ||
| log_format_local_dev_enabled=_settings.STORAGE_LOG_FORMAT_LOCAL_DEV_ENABLED, | ||
| logger_filter_mapping=_settings.STORAGE_LOG_FILTER_MAPPING, | ||
| tracing_config=_tracing_config, | ||
| log_base_level=_settings.log_level, | ||
| noisy_loggers=None, | ||
| ) | ||
|
|
||
| assert _settings.STORAGE_CELERY # nosec | ||
| app = create_celery_app(_settings.STORAGE_CELERY) | ||
| setup_worker_tasks(app) | ||
|
|
||
| return app | ||
|
|
||
|
|
||
| the_app = get_app() | ||
giancarloromeo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @worker_init.connect | ||
| @worker_process_init.connect | ||
| def worker_init_wrapper(**kwargs): | ||
giancarloromeo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fastapi_app = create_app(_settings, tracing_config=_tracing_config) | ||
| app_server = FastAPIAppServer(app=fastapi_app) | ||
| set_app_server(the_app, app_server) | ||
| return on_worker_init(app_server, **kwargs) | ||
|
|
||
|
|
||
| @worker_shutdown.connect | ||
| @worker_process_shutdown.connect | ||
| def worker_shutdown_wrapper(**kwargs): | ||
| app_server = get_app_server(the_app) | ||
| return on_worker_shutdown(app_server, **kwargs) | ||
46 changes: 0 additions & 46 deletions
46
services/storage/src/simcore_service_storage/modules/celery/worker_main.py
This file was deleted.
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.
Uh oh!
There was an error while loading. Please reload this page.