Cleaner async I/O syntax with Qt

Patrick Stinson patrickkidd at gmail.com
Mon Dec 20 18:20:23 GMT 2021


Hello,

I am using QNetworkAccessManager / QNetworkRequest for my async http requests. I am trying to find a way to wrap these in a cleaner python syntax. My first though was an async context manager, effectively like this:

with qt_request('https://google.com <https://google.com/>') as response:
    # executed later
    print(response.body)
# executed now
print("Sent request...")

I have been reading the docs on async context managers, but haven’t gotten the concepts into my head yet. Probably because I don’t fully get the async and await keywords yet either. Maybe this is actually counter to the python language spec?

Cheers,
-Patrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20211220/29b6f0d7/attachment.htm>


More information about the PyQt mailing list