{"library":"qasync","title":"qasync","description":"qasync is a Python library for using asyncio in Qt-based applications, allowing developers to seamlessly integrate asynchronous code into their Qt GUI projects. It is currently at version 0.28.0 and maintains a regular release cadence with updates for new Python versions and performance improvements.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install qasync"],"cli":null},"imports":["from qasync import QEventLoopPolicy","from qasync import asyncSlot","from qasync import asyncClose","from qasync import QAsyncApplication"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import asyncio\nimport sys\n\n# Choose your Qt binding: PyQt5, PyQt6, PySide2, PySide6\n# For this example, we'll use PyQt5\nfrom PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget, QPushButton\n\nfrom qasync import QEventLoopPolicy, asyncSlot\n\nasync def long_running_task(duration_seconds: int = 2):\n    \"\"\"A mock asynchronous task.\"\"\"\n    print(f\"[Task] Starting long-running task for {duration_seconds} seconds...\")\n    await asyncio.sleep(duration_seconds)\n    print(\"[Task] Long-running task finished!\")\n    return \"Task Completed!\"\n\nclass MainWindow(QWidget):\n    def __init__(self):\n        super().__init__()\n        self.setWindowTitle(\"qasync Quickstart Demo\")\n        self.setGeometry(100, 100, 400, 200)\n\n        self.layout = QVBoxLayout()\n        self.label = QLabel(\"Click the button to start an async task.\")\n        self.button = QPushButton(\"Run Async Task\")\n\n        # Connect a Qt signal to an asynchronous slot using @asyncSlot\n        self.button.clicked.connect(self.run_task)\n\n        self.layout.addWidget(self.label)\n        self.layout.addWidget(self.button)\n        self.setLayout(self.layout)\n\n    @asyncSlot()\n    async def run_task(self):\n        \"\"\"This slot runs an async task without blocking the GUI.\"\"\"\n        self.label.setText(\"Task started, please wait...\")\n        self.button.setEnabled(False) # Disable button while task is running\n\n        result = await long_running_task(3) # Await the async task\n        \n        self.label.setText(f\"Result: {result}\")\n        self.button.setEnabled(True) # Re-enable button\n\nif __name__ == \"__main__\":\n    # IMPORTANT: Set the asyncio event loop policy *before* creating QApplication\n    asyncio.set_event_loop_policy(QEventLoopPolicy())\n\n    app = QApplication(sys.argv)\n    window = MainWindow()\n    window.show()\n    \n    # Run the Qt application\n    sys.exit(app.exec_())\n","lang":"python","description":"This quickstart demonstrates how to integrate `asyncio` with a basic Qt application using `qasync`. It shows how to set the `QEventLoopPolicy`, create an `asyncSlot` for a button click, and run an `asyncio` task without blocking the GUI.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.28.0","pypi_latest":"0.28.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":1.5,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.4M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.5,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"qasync","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"18M"}]}}