Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2561

QAsyncioTask is not awaitable

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.6.2, 6.7.0
    • 6.6.1
    • QtAsyncio
    • None
    • Windows with PySide 6.6.1
    • 8c9ad6eac (dev), 5d9d8c2f5 (6.6)

    Description

      I know QtAsyncio is still experimental, but it seemed to be working quite well in our application as a replacement for qasync, so I thought I'd report this anyway.

      According to the documentation for Tasks (https://docs.python.org/3/library/asyncio-task.html#asyncio.Task), they are "future-like" and while it does not explicitly say they are awaitable, some of the example code does show a task being awaited:

      async def main():
          # Create a "cancel_me" Task
          task = asyncio.create_task(cancel_me())
      
          # Wait for 1 second
          await asyncio.sleep(1)
      
          task.cancel()
          try:
              await task
          except asyncio.CancelledError:
              print("main(): cancel_me is cancelled now") 

      However, the QtAsyncio implementation of a task (QAsyncioTask) throws an error when the task is awaited "PySide6.QtAsyncio.tasks.QAsyncioTask.QtTaskApiMisuseError: Tasks cannot be awaited" from https://code.qt.io/cgit/pyside/pyside-setup.git/tree/sources/pyside6/PySide6/QtAsyncio/tasks.py?id=ba4ec692228d9f9d24abe7e99c8612060c1d1de9#n47

      There needs to be some way of waiting for a task to complete, so could QAsyncioTask be awaitable?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            adherrma Adrian Herrmann
            matsjoyce-refeyn Matthew Joyce
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes