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

QAsyncioTask does not handle cancelling correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • 6.8.0, 6.7.3
    • 6.7.1
    • QtAsyncio
    • None
    • 526bc12e4 (dev), 5fe76b7be (6.7)

    Description

      Minimal Example:

      import asyncio
      from PySide6.QtCore import *
      from PySide6.QtWidgets import *
      import PySide6.QtAsyncio as QtAsyncio
      products = list()
      async def producer():
          while True:
              products.append('product')
              await asyncio.sleep(5)
      async def task():
          asyncio.ensure_future(producer())
          while True:
              try:
                  async with asyncio.timeout(1):
                      while len(products) == 0:
                          await asyncio.sleep(0)
                      print(products.pop(0))
              except TimeoutError:
                  print('Timeout') # Never Timeout
      def main():
          QApplication([])
          QtAsyncio.run(task())
          # asyncio.run(task())
      main()

      Attachments

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

        Activity

          People

            adherrma Adrian Herrmann (Inactive)
            windmill_city Fudong Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes