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

Pyside6 with Python asyncio AbstractAsyncContextManager to manage eventloop lifetime

    XMLWordPrintable

Details

    • User Story
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • QtAsyncio
    • None

    Description

      As a Python Developer who uses PySide to execute tasks in a background thread, I would like to use PySide and Python's asyncio features within an context manager that manages additional async tasks that could start prior to exec() so that I can use the same  eventloop used by QtAsyncio.run but start co-routines prior or simultaneously to opening the window.

      Just having asyncio is awesome but I wish I could send QtAsyncio.run() an object that supports the AbstractContextManager or (even better) Async AbstractAsyncContextManager interfaces so that I could easily clean up any Tasks/Futures not started or finished after the main window closes but the event loop has ended. Basically work like a destructor.

       

      Basically I want to run this within a context manager that manages the event loop lifespan.....

      1. Start event loop
      2. Start background consumer co-routine with a shared Queue object.
      3. Start Qt Application window and show window. Buttons add jobs to Queue object mentioned in step 2.
      4. On exit of Qt Application (after returning from the exec() call), keep event loop open so that it allows me to manually clean up Queue and wait for background consumer co-routine to fully await

       

       

      Attachments

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

        Activity

          People

            adherrma Adrian Herrmann (Inactive)
            henryborchers Henry Borchers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes