Skip to content

High CPU usage when using asyncio.open_connection #28

@saint83

Description

@saint83

Hello all

I am currently hitting some performance issue on a GUI app that uses PyQT5 and asyncio as backend.
After multiple test I figured out that CPU is 100% used when asyncio.open_connection is used

import asyncio
import sys

from PyQt5.QtWidgets import QApplication
from qasync import QEventLoop

async def start_client():

reader, writer = await asyncio.open_connection('127.0.0.1', 45678)

while True:
    print("LOOP")
    await asyncio.sleep(2)

if name == 'main':
app = QApplication(sys.argv)
loop = QEventLoop()
loop.create_task(start_client())
loop.run_forever()

When running above code, CPU usage is 100%. If loop = asyncio.get_event_loop() it's used, this issue is not seen

Python 3.9.0
PyQt5 5.15.2
qasync 0.13.0

Do you have any idea why this is happening?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions