django-threaded-sync-to-async


Namedjango-threaded-sync-to-async JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/excitoon/django_threaded_sync_to_async
SummaryTools for replacing `sync_to_async` calls to `sync_to_async(thread_sensitive=False, executor=...)`, effectively allowing Django to make calls to database concurrently
upload_time2023-05-30 08:48:32
maintainer
docs_urlNone
authorVladimir Chebotarev
requires_python
licenseMIT
keywords django asyncio asgiref sync_to_async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## `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`

```python3
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.

```python3
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)
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/excitoon/django_threaded_sync_to_async",
    "name": "django-threaded-sync-to-async",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,asyncio,asgiref,sync_to_async",
    "author": "Vladimir Chebotarev",
    "author_email": "vladimir.chebotarev@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/09/be/051c54463ce4b88ff3cfcf15acf24b32ada0e237ff6a5c9d1ea95ab39669/django_threaded_sync_to_async-1.0.4.tar.gz",
    "platform": null,
    "description": "## `django_threaded_sync_to_async`\n\nTools for replacing `sync_to_async` calls to `sync_to_async(thread_sensitive=False, executor=...)`, effectively allowing Django to make calls to database concurrently.\n\n```\npip3 install django_threaded_sync_to_async\n```\n\n### `Executor`\n\n```python3\nimport django_threaded_sync_to_async\n\nasync with django_threaded_sync_to_async.Executor(thread_name_prefix=\"thread\", max_workers=3) as executor:\n    a = asgiref.sync.sync_to_async(long_call)(1)\n    b = asgiref.sync.sync_to_async(long_call)(2)\n    c = asgiref.sync.sync_to_async(long_call)(3)\n    d = asgiref.sync.sync_to_async(long_call)(4)\n    await asyncio.gather(a, b, c, d)\n```\n\n### `SharedExecutor`\n\nMaintains global dictionary of executors (`concurrent.futures.ThreadPoolExecutor`) accessed by name and allows to limit utilization of executor for a single context.\n\n```python3\nimport django_threaded_sync_to_async\n\n@django_threaded_sync_to_async.SharedExecutor(\"common\", max_workers=3, max_tasks=2)\nasync def operations():\n    a = asgiref.sync.sync_to_async(long_call)(1)\n    b = asgiref.sync.sync_to_async(long_call)(2)\n    c = asgiref.sync.sync_to_async(long_call)(3)\n    d = asgiref.sync.sync_to_async(long_call)(4)\n    await asyncio.gather(a, b, c, d)\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tools for replacing `sync_to_async` calls to `sync_to_async(thread_sensitive=False, executor=...)`, effectively allowing Django to make calls to database concurrently",
    "version": "1.0.4",
    "project_urls": {
        "Documentation": "https://github.com/excitoon/django_threaded_sync_to_async/blob/master/README.md",
        "Homepage": "https://github.com/excitoon/django_threaded_sync_to_async",
        "Source": "https://github.com/excitoon/django_threaded_sync_to_async",
        "Tracker": "https://github.com/excitoon/django_threaded_sync_to_async/issues"
    },
    "split_keywords": [
        "django",
        "asyncio",
        "asgiref",
        "sync_to_async"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09be051c54463ce4b88ff3cfcf15acf24b32ada0e237ff6a5c9d1ea95ab39669",
                "md5": "f28e41fd8418252b9aafd72f629c5a07",
                "sha256": "776cc51333d11d3669c690e2c2cb50ad81884cad718b1eb7f764f4db7ae097a1"
            },
            "downloads": -1,
            "filename": "django_threaded_sync_to_async-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "f28e41fd8418252b9aafd72f629c5a07",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6683,
            "upload_time": "2023-05-30T08:48:32",
            "upload_time_iso_8601": "2023-05-30T08:48:32.552839Z",
            "url": "https://files.pythonhosted.org/packages/09/be/051c54463ce4b88ff3cfcf15acf24b32ada0e237ff6a5c9d1ea95ab39669/django_threaded_sync_to_async-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-30 08:48:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "excitoon",
    "github_project": "django_threaded_sync_to_async",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "django-threaded-sync-to-async"
}
        
Elapsed time: 0.45529s