Runner framework for aiohttp
Project description
Run jobs in the background of an aiohttp server.
Usage
Define a service
import asyncio
from some_aiohttp_service import BaseService
async def some_long_calculation(a, b):
await asyncio.sleep(5)
return f"Done with {a}/{b}"
class TestService(BaseService):
name = "test"
@staticmethod
async def work(job):
return await some_long_calculation(**job.data)
async def error_handler(self, job, error):
print("Error", error)
async def result_handler(self, job, result):
print(result)
Set up an aiohttp server:
from aiohttp.web import Application, get, run_app
from aiohttp.web_exceptions import HTTPOk, HTTPAccepted
async def health(_):
raise HTTPOk
async def hello(request):
a = request.match_info["a"]
b = request.match_info["b"]
await request.app["test"].commit_work({"a": a, "b": b})
raise HTTPAccepted
app = Application()
app.add_routes([get("/work/{a}/{b}", hello), get("/health", health)])
app.cleanup_ctx.append(TestService(app).init)
run_app(app)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file some_aiohttp_service-0.1.7.tar.gz.
File metadata
- Download URL: some_aiohttp_service-0.1.7.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65744c88fad048c161064ef809e9f0efdcbc077a99534ccc468773fe9a582048
|
|
| MD5 |
c0e599b55fd9131b1d7982513ec81ace
|
|
| BLAKE2b-256 |
b12bb690f5ebb3ea3fa1279739feb602a90760eea6b998e1af13703b58bf985f
|
Provenance
The following attestation bundles were made for some_aiohttp_service-0.1.7.tar.gz:
Publisher:
ci.yml on tommmlij/some-aiohttp-service
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
some_aiohttp_service-0.1.7.tar.gz -
Subject digest:
65744c88fad048c161064ef809e9f0efdcbc077a99534ccc468773fe9a582048 - Sigstore transparency entry: 152011657
- Sigstore integration time:
-
Permalink:
tommmlij/some-aiohttp-service@a0abcad9cbffaf9c22ac7498c5d8b301ccf424c3 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/tommmlij
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@a0abcad9cbffaf9c22ac7498c5d8b301ccf424c3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file some_aiohttp_service-0.1.7-py3-none-any.whl.
File metadata
- Download URL: some_aiohttp_service-0.1.7-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4261448724f5719ed514b59fb8cf90dfb5392018657a643087d71edb02b8f11c
|
|
| MD5 |
1c92b9f6ad55c36581b37ebf0d5be45b
|
|
| BLAKE2b-256 |
9c8fae0ec60d46557036b5037c70f2a38d0fb36dc07aa0427e9d8bc155e494bf
|
Provenance
The following attestation bundles were made for some_aiohttp_service-0.1.7-py3-none-any.whl:
Publisher:
ci.yml on tommmlij/some-aiohttp-service
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
some_aiohttp_service-0.1.7-py3-none-any.whl -
Subject digest:
4261448724f5719ed514b59fb8cf90dfb5392018657a643087d71edb02b8f11c - Sigstore transparency entry: 152011661
- Sigstore integration time:
-
Permalink:
tommmlij/some-aiohttp-service@a0abcad9cbffaf9c22ac7498c5d8b301ccf424c3 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/tommmlij
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@a0abcad9cbffaf9c22ac7498c5d8b301ccf424c3 -
Trigger Event:
push
-
Statement type: