Skip to main content

django_threaded_sync_to_async

Tools for replacing sync_to_async calls to sync_to_async(thread_sensitive=False, executor=...), effectively allowing Django to make calls to database concurrently.

pip3 install django_threaded_sync_to_async

Executor

import django_threaded_sync_to_async

async with django_threaded_sync_to_async.Executor(thread_name_prefix="thread", max_workers=3) as executor:
    a = asgiref.sync.sync_to_async(long_call)(1)
    b = asgiref.sync.sync_to_async(long_call)(2)
    c = asgiref.sync.sync_to_async(long_call)(3)
    d = asgiref.sync.sync_to_async(long_call)(4)
    await asyncio.gather(a, b, c, d)

SharedExecutor

Maintains global dictionary of executors (concurrent.futures.ThreadPoolExecutor) accessed by name and allows to limit utilization of executor for a single context.

import django_threaded_sync_to_async

@django_threaded_sync_to_async.SharedExecutor("common", max_workers=3, max_tasks=2)
async def operations():
    a = asgiref.sync.sync_to_async(long_call)(1)
    b = asgiref.sync.sync_to_async(long_call)(2)
    c = asgiref.sync.sync_to_async(long_call)(3)
    d = asgiref.sync.sync_to_async(long_call)(4)
    await asyncio.gather(a, b, c, d)

Metadata

Release files for django-threaded-sync-to-async 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-threaded-sync-to-async 1.0.4
File Size Uploaded Provenance Actions
django_threaded_sync_to_async-1.0.4.tar.gz 6.7 kB Without provenance Details for django_threaded_sync_to_async-1.0.4.tar.gz

Release files / django_threaded_sync_to_async-1.0.4.tar.gz

Download URL django_threaded_sync_to_async-1.0.4.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
776cc51333d11d3669c690e2c2cb50ad81884cad718b1eb7f764f4db7ae097a1
BLAKE2b-256 checksum
How to use checksums
09be051c54463ce4b88ff3cfcf15acf24b32ada0e237ff6a5c9d1ea95ab39669
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.5

Security for django-threaded-sync-to-async 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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