qasync


Nameqasync JSON
Version 0.28.0 PyPI version JSON
download
home_pageNone
SummaryPython library for using asyncio in Qt-based applications
upload_time2025-08-28 01:31:36
maintainerAlex March
docs_urlNone
authorArve Knudsen, Gerard Marull-Paretas, Mark Harviston, Alex March, Sam McCormack
requires_python>=3.8
licenseNone
keywords qt asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # qasync

[![Maintenance](https://img.shields.io/maintenance/yes/2025)](https://pypi.org/project/qasync)
[![PyPI](https://img.shields.io/pypi/v/qasync)](https://pypi.org/project/qasync)
[![PyPI - License](https://img.shields.io/pypi/l/qasync)](/LICENSE)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qasync)](https://pypi.org/project/qasync)
[![PyPI - Download](https://img.shields.io/pypi/dm/qasync)](https://pypi.org/project/qasync)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/CabbageDevelopment/qasync/main.yml)](https://github.com/CabbageDevelopment/qasync/actions/workflows/main.yml)

## Introduction

`qasync` allows coroutines to be used in PyQt/PySide applications by providing an implementation of the `PEP 3156` event loop.

With `qasync`, you can use `asyncio` functionalities directly inside Qt app's event loop, in the main thread. Using async functions for Python tasks can be much easier and cleaner than using `threading.Thread` or `QThread`.

If you need some CPU-intensive tasks to be executed in parallel, `qasync` also got that covered, providing `QEventLoop.run_in_executor` which is functionally identical to that of `asyncio`. By default `QThreadExecutor` is used, but any class implementing the `concurrent.futures.Executor` interface will do the job.

### Basic Example

```python
import asyncio
import sys

from PySide6.QtWidgets import QVBoxLayout, QWidget

from qasync import QApplication, QEventLoop


class MainWindow(QWidget):
    def __init__(self):
        super().__init__()

        self.setLayout(QVBoxLayout())
        self.lbl_status = QLabel("Idle", self)
        self.layout().addWidget(self.lbl_status)

    @asyncClose
    async def closeEvent(self, event):
        pass

    @asyncSlot()
    async def onMyEvent(self):
        pass


if __name__ == "__main__":
    app = QApplication(sys.argv)

    app_close_event = asyncio.Event()
    app.aboutToQuit.connect(app_close_event.set)

    main_window = MainWindow()
    main_window.show()

    # for 3.11 or older use qasync.run instead of asyncio.run
    # qasync.run(app_close_event.wait())
    asyncio.run(app_close_event.wait(), loop_factory=QEventLoop)
```

More detailed examples can be found [here](https://github.com/CabbageDevelopment/qasync/tree/master/examples).

### The Future of `qasync`

`qasync` is a fork of [asyncqt](https://github.com/gmarull/asyncqt), which is a fork of [quamash](https://github.com/harvimt/quamash). `qasync` was created because those are no longer maintained. May it live longer than its predecessors.

**`qasync` will continue to be maintained, and will still be accepting pull requests.**

## Requirements

- Python >=3.8, <3.14
- PyQt5/PyQt6 or PySide2/PySide6

`qasync` is tested on Ubuntu, Windows and MacOS.

If you need Python 3.6 or 3.7 support, use the [v0.25.0](https://github.com/CabbageDevelopment/qasync/releases/tag/v0.25.0) tag/release.

## Installation

To install `qasync`, use `pip`:

```
pip install qasync
```

## License

You may use, modify and redistribute this software under the terms of the [BSD License](http://opensource.org/licenses/BSD-2-Clause). See [LICENSE](/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "qasync",
    "maintainer": "Alex March",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Alex March <alexmach@fastmail.com>",
    "keywords": "Qt, asyncio",
    "author": "Arve Knudsen, Gerard Marull-Paretas, Mark Harviston, Alex March, Sam McCormack",
    "author_email": "Arve Knudsen <arve.knudsen@gmail.com>, Gerard Marull-Paretas <gerard@teslabs.com>, Mark Harviston <mark.harviston@gmail.com>, Alex March <alexmarch@fastmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ec/b2/5be08597dbbf331edb69478eae2f8dd511834cebf56a183b442e7437f8e0/qasync-0.28.0.tar.gz",
    "platform": null,
    "description": "# qasync\n\n[![Maintenance](https://img.shields.io/maintenance/yes/2025)](https://pypi.org/project/qasync)\n[![PyPI](https://img.shields.io/pypi/v/qasync)](https://pypi.org/project/qasync)\n[![PyPI - License](https://img.shields.io/pypi/l/qasync)](/LICENSE)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qasync)](https://pypi.org/project/qasync)\n[![PyPI - Download](https://img.shields.io/pypi/dm/qasync)](https://pypi.org/project/qasync)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/CabbageDevelopment/qasync/main.yml)](https://github.com/CabbageDevelopment/qasync/actions/workflows/main.yml)\n\n## Introduction\n\n`qasync` allows coroutines to be used in PyQt/PySide applications by providing an implementation of the `PEP 3156` event loop.\n\nWith `qasync`, you can use `asyncio` functionalities directly inside Qt app's event loop, in the main thread. Using async functions for Python tasks can be much easier and cleaner than using `threading.Thread` or `QThread`.\n\nIf you need some CPU-intensive tasks to be executed in parallel, `qasync` also got that covered, providing `QEventLoop.run_in_executor` which is functionally identical to that of `asyncio`. By default `QThreadExecutor` is used, but any class implementing the `concurrent.futures.Executor` interface will do the job.\n\n### Basic Example\n\n```python\nimport asyncio\nimport sys\n\nfrom PySide6.QtWidgets import QVBoxLayout, QWidget\n\nfrom qasync import QApplication, QEventLoop\n\n\nclass MainWindow(QWidget):\n    def __init__(self):\n        super().__init__()\n\n        self.setLayout(QVBoxLayout())\n        self.lbl_status = QLabel(\"Idle\", self)\n        self.layout().addWidget(self.lbl_status)\n\n    @asyncClose\n    async def closeEvent(self, event):\n        pass\n\n    @asyncSlot()\n    async def onMyEvent(self):\n        pass\n\n\nif __name__ == \"__main__\":\n    app = QApplication(sys.argv)\n\n    app_close_event = asyncio.Event()\n    app.aboutToQuit.connect(app_close_event.set)\n\n    main_window = MainWindow()\n    main_window.show()\n\n    # for 3.11 or older use qasync.run instead of asyncio.run\n    # qasync.run(app_close_event.wait())\n    asyncio.run(app_close_event.wait(), loop_factory=QEventLoop)\n```\n\nMore detailed examples can be found [here](https://github.com/CabbageDevelopment/qasync/tree/master/examples).\n\n### The Future of `qasync`\n\n`qasync` is a fork of [asyncqt](https://github.com/gmarull/asyncqt), which is a fork of [quamash](https://github.com/harvimt/quamash). `qasync` was created because those are no longer maintained. May it live longer than its predecessors.\n\n**`qasync` will continue to be maintained, and will still be accepting pull requests.**\n\n## Requirements\n\n- Python >=3.8, <3.14\n- PyQt5/PyQt6 or PySide2/PySide6\n\n`qasync` is tested on Ubuntu, Windows and MacOS.\n\nIf you need Python 3.6 or 3.7 support, use the [v0.25.0](https://github.com/CabbageDevelopment/qasync/releases/tag/v0.25.0) tag/release.\n\n## Installation\n\nTo install `qasync`, use `pip`:\n\n```\npip install qasync\n```\n\n## License\n\nYou may use, modify and redistribute this software under the terms of the [BSD License](http://opensource.org/licenses/BSD-2-Clause). See [LICENSE](/LICENSE).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python library for using asyncio in Qt-based applications",
    "version": "0.28.0",
    "project_urls": {
        "Homepage": "https://github.com/CabbageDevelopment/qasync",
        "Releases": "https://github.com/CabbageDevelopment/qasync/releases",
        "Repository": "https://github.com/CabbageDevelopment/qasync",
        "Tracker": "https://github.com/CabbageDevelopment/qasync/issues"
    },
    "split_keywords": [
        "qt",
        " asyncio"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e5840ce4cd946f6e958428c87d5accac35df70f81607e45ba4919947d0762d63",
                "md5": "29322ff3010e98d4e5a11e8799f3d6ac",
                "sha256": "21faba8d047c717008378f5ac29ea58c32a8128528629e4afd57c59b768dba0f"
            },
            "downloads": -1,
            "filename": "qasync-0.28.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "29322ff3010e98d4e5a11e8799f3d6ac",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 16188,
            "upload_time": "2025-08-28T01:31:35",
            "upload_time_iso_8601": "2025-08-28T01:31:35.591501Z",
            "url": "https://files.pythonhosted.org/packages/e5/84/0ce4cd946f6e958428c87d5accac35df70f81607e45ba4919947d0762d63/qasync-0.28.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ecb25be08597dbbf331edb69478eae2f8dd511834cebf56a183b442e7437f8e0",
                "md5": "456a269c14576094ad8e2e7f1bb1948f",
                "sha256": "6f7f1f18971f59cb259b107218269ba56e3ad475ec456e54714b426a6e30b71d"
            },
            "downloads": -1,
            "filename": "qasync-0.28.0.tar.gz",
            "has_sig": false,
            "md5_digest": "456a269c14576094ad8e2e7f1bb1948f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14010,
            "upload_time": "2025-08-28T01:31:36",
            "upload_time_iso_8601": "2025-08-28T01:31:36.785837Z",
            "url": "https://files.pythonhosted.org/packages/ec/b2/5be08597dbbf331edb69478eae2f8dd511834cebf56a183b442e7437f8e0/qasync-0.28.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-28 01:31:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CabbageDevelopment",
    "github_project": "qasync",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "qasync"
}
        
Elapsed time: 1.99326s