Metadata-Version: 2.4
Name: bedrock-celery
Version: 0.1.0
Summary: Celery integration for Bedrock: per-process worker lifecycle, per-task DI scopes and database sessions, and async tasks.
Keywords: bedrock,celery,worker,tasks
Author: maacck
Author-email: maacck <c.mai@madainchina.com>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Celery
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Dist: bedrock-core>=0.3.2
Requires-Dist: celery>=5.3
Requires-Python: >=3.12
Project-URL: Bug Tracker, https://github.com/maacck/bedrock-py/issues
Project-URL: Documentation, https://bedrock-py.com
Project-URL: Homepage, https://bedrock-py.com
Project-URL: Repository, https://github.com/maacck/bedrock-py
Description-Content-Type: text/markdown

# bedrock-celery

Celery integration for [Bedrock](https://bedrock-py.com). Your application creates and owns the Celery app;
this package supplies pieces you add as needed:

- `connect_worker(app)`: runs `bedrock.setup()` in each worker process (after the fork with the prefork pool)
  and `bedrock.shutdown()` when the process exits.
- `BedrockTask`: each task runs in its own Bedrock DI scope and database session. Services commit; uncommitted
  work is rolled back when the task ends. `async def` tasks run with `bedrock.run_async()` on Bedrock's runtime
  loop with `db.asession`.

```python
from bedrock.database import db
from bedrock_celery import BedrockTask, connect_worker
from celery import Celery

app = Celery("shop", broker="redis://localhost:6379/0", task_cls=BedrockTask)
db.init()
connect_worker("shop.inventory")
```

See the Celery integration docs at https://bedrock-py.com/docs/integrations/celery for installation, the
transaction convention, async tasks, and testing.
