Install & Compatibility
Where this runs
tested against v0.28.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
QEventLoop
✓ from qasync import QEventLoop
✗ import qasync
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.
import asyncio
import sys
# Choose your Qt binding: PyQt5, PyQt6, PySide2, PySide6
# For this example, we'll use PyQt5
from PyQt5.QtWidgets import QApplication, QLabel, QVBoxLayout, QWidget, QPushButton
from qasync import QEventLoopPolicy, asyncSlot
async def long_running_task(duration_seconds: int = 2):
"""A mock asynchronous task."""
print(f"[Task] Starting long-running task for {duration_seconds} seconds...")
await asyncio.sleep(duration_seconds)
print("[Task] Long-running task finished!")
return "Task Completed!"
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("qasync Quickstart Demo")
self.setGeometry(100, 100, 400, 200)
self.layout = QVBoxLayout()
self.label = QLabel("Click the button to start an async task.")
self.button = QPushButton("Run Async Task")
# Connect a Qt signal to an asynchronous slot using @asyncSlot
self.button.clicked.connect(self.run_task)
self.layout.addWidget(self.label)
self.layout.addWidget(self.button)
self.setLayout(self.layout)
@asyncSlot()
async def run_task(self):
"""This slot runs an async task without blocking the GUI."""
self.label.setText("Task started, please wait...")
self.button.setEnabled(False) # Disable button while task is running
result = await long_running_task(3) # Await the async task
self.label.setText(f"Result: {result}")
self.button.setEnabled(True) # Re-enable button
if __name__ == "__main__":
# IMPORTANT: Set the asyncio event loop policy *before* creating QApplication
asyncio.set_event_loop_policy(QEventLoopPolicy())
app = QApplication(sys.argv)
window = MainWindow()
window.show()
# Run the Qt application
sys.exit(app.exec_())
Upgrade
Version history
0.28.0latest on PyPI · released Aug 28, 2025
Audit
Dependencies
PyQt5optionalqasync requires one of the Qt bindings to function.
PyQt6optionalqasync requires one of the Qt bindings to function.
PySide2optionalqasync requires one of the Qt bindings to function.
PySide6optionalqasync requires one of the Qt bindings to function.