Skip to main content

ashka

CI Publish Update dishka

ashka extends reagento/dishka with async/sync application lifecycle support.

The a prefix lets ashka sort before dishka, helping ensure the correct import order. The name also means async application lifecycle support, which can speed up startup compared with serially initializing components in a lifespan function.

Application Lifecycle

This feature requires the ashka[lifecycle] extra.

Declare the resources that must be ready before the application starts doing work. Ashka initializes them with the application. During runtime, they follow dishka's APP-scope behavior. When the container closes, dishka closes generator-based resources:

from collections.abc import AsyncIterator

import ashka
from ashka import AshkaScope, async_lifespan, provide
from dishka import Provider, make_async_container
from fastapi import FastAPI


class Database:
    async def connect(self) -> None: ...

    async def close(self) -> None: ...


class ApplicationProvider(Provider):
    @provide(scope=AshkaScope.BOOTSTRAP)
    async def database(self) -> AsyncIterator[Database]:
        database = Database()
        await database.connect()
        yield database
        await database.close()


app = FastAPI(lifespan=async_lifespan)
container = make_async_container(ApplicationProvider())

ashka.integrations.setup_dishka(container, app)
  • Startup: Bootstrap dependencies are initialized before the application starts doing work.
  • Runtime: Dependencies retain dishka's APP-scope caching and dependency behavior.
  • Shutdown: Dishka closes generator-based resources with the container.

Independent asynchronous Bootstrap dependencies initialize concurrently. When initialization order matters, express it through provider parameters.

Container Access

This feature is available in the base ashka package and does not require the lifecycle extra.

Attach a container through the central integration entry point, then retrieve the same container wherever the framework object is available:

import ashka
from dishka import make_async_container
from fastapi import FastAPI


app = FastAPI()
container = make_async_container()

ashka.integrations.setup_dishka(container, app)

assert ashka.integrations.get_container(app) is container

The central entry points dispatch to the corresponding integration from the runtime type of the framework object.

Documentation

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ashka-0.9.5.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ashka-0.9.5-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file ashka-0.9.5.tar.gz.

File metadata

  • Download URL: ashka-0.9.5.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ashka-0.9.5.tar.gz
Algorithm Hash digest
SHA256 6bfad7ed647eda10570e33a5db69a67a3229bc05b7210cbe438ad5c2241d13a7
MD5 18ec8e361db0d68a393f941e4751af5f
BLAKE2b-256 4571dcc6346a57fdfde3f7fd2564d8f77bfac4db9fe4262adfd1e330dd847dc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ashka-0.9.5.tar.gz:

Publisher: publish.yml on handsome-Druid/ashka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ashka-0.9.5-py3-none-any.whl.

File metadata

  • Download URL: ashka-0.9.5-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ashka-0.9.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1191ce408c5eb698adfa10d4ca148611ec21fa0165d1e3179d4c8981e7a3b5e7
MD5 e7537a8ee4fb52e9070c703802b7634f
BLAKE2b-256 4a2ecb21a9120c33335dee436074bdf86c1d99a0a677751d003f48082f15f99e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ashka-0.9.5-py3-none-any.whl:

Publisher: publish.yml on handsome-Druid/ashka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.9.7

2 files

0.9.6

2 files

This release

0.9.5 This release

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.8

2 files

0.8.7

2 files

0.8.6

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.1

2 files

0.8.0

2 files

0.6.0

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page