Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.7
-
None
Description
Hello,
I'm working on a PySide6 project where I'm doing async API calls through a library that uses aiohttp. However, whenever I try to execute a request, I get the following error:
QtTask.cancelling is not implemented
Here is the minimal asyncio example from the documentation that I've tweaked a little to simply reproduce this error (the main changes being in the set_text method) :
from PySide6.QtCore import Qt from PySide6.QtWidgets import (QApplication, QLabel, QMainWindow, QPushButton, QVBoxLayout, QWidget) import PySide6.QtAsyncio as QtAsyncio import asyncio import aiohttp import sys class MainWindow(QMainWindow): def __init__(self): super().__init__() widget = QWidget() self.setCentralWidget(widget) layout = QVBoxLayout(widget) self.text = QLabel("Result: ") layout.addWidget(self.text, alignment=Qt.AlignmentFlag.AlignCenter) async_trigger = QPushButton(text="Fetch something using aiohttp: ") async_trigger.clicked.connect(lambda: asyncio.ensure_future(self.set_text())) layout.addWidget(async_trigger, alignment=Qt.AlignmentFlag.AlignCenter) async def set_text(self): async with aiohttp.ClientSession(loop=asyncio.get_event_loop()) as session: async with session.get("http://www.numbersapi.com/42") as response: result = str(await response.read()) self.text.setText(result) if __name__ == "__main__": app = QApplication(sys.argv) main_window = MainWindow() main_window.show() QtAsyncio.run()
Since it doesn't work, I rewrote the lib I'm using with the QtNetwork module. It works, but it required a lot more code. Being able to use the aiohttp version would be way better.
Thanks for reading this, and thanks a lot for your work on the QtAsyncio module !