Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Using websockets with QtAsyncio
Forum Updated to NodeBB v4.3 + New Features

Using websockets with QtAsyncio

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 122 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    batton
    wrote 16 days ago last edited by
    #1

    The documentation states that:

    "We consider that this API consists of two levels:

    1. Fundamental infrastructure for event loops and asynchronous operations, including futures, tasks, handles, executors, and event loop management functions (see below).
    2. A user-facing API for use in applications, including transports and protocols, network connections, servers, sockets, signals, subprocesses.
      QtAsyncio currently covers the first level. This includes the following functions, for which the API is identical with QtAsyncio as with asyncio"

    I didn't understand the significance of this, until I tried to use websockets in my code using QtAsyncio as the event loop:

    async def my_coroutine():
        while True:
            print("Running coroutine")
            await asyncio.sleep(1)  # Simulate non-blocking operation
            async with connect("ws://localhost:8765") as websocket:
                await asyncio.sleep(5)
    

    The code is just to illustrate the error, which is:

    NotImplementedError: QAsyncioEventLoop.create_connection() is not implemented yet
    

    I've been messing around with separate Threads running their own event loops. I need to have a slot respond to a signal and send out a websocket message.

    Would it make sense to have the signal handling socket running in a separate Thread that uses an asyncio event loop, or is there a more elegant workaraound for this?

    1 Reply Last reply
    0

    1/1

    4 Jun 2025, 19:21

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved