-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trio warning when exiting the application #262
Comments
Also, I tried to reproduce the issue with a minimal example but I couldn't. There's probably more to it, here's my attempt: import trio
import qtrio
from PyQt5.QtWidgets import QApplication, QMainWindow
async def task():
stream = await trio.open_tcp_stream("localhost", 8000)
await stream.send_all(b"test")
await stream.receive_some()
async def main():
window = QMainWindow()
window.show()
async with trio.open_nursery() as nursery:
nursery.start_soon(task)
await trio.sleep(1)
window.close()
QApplication.quit()
if __name__ == "__main__":
qtrio.run(main) Run with: nc localhost -l 8000 & python test.py |
I realized import trio
import qtrio
from PyQt5.QtWidgets import QApplication, QMainWindow
async def task(window):
await trio.sleep(1)
window.close()
QApplication.quit()
async def main():
try:
window = QMainWindow()
window.show()
async with trio.open_nursery() as nursery:
nursery.start_soon(task, window)
await trio.sleep(3)
finally:
print("Very important stuff!")
if __name__ == "__main__":
qtrio.run(main) |
Do you need to call Line 731 in cdd3fe7
https://qtrio.readthedocs.io/en/v0.4.2/core.html#qtrio.Runner.quit_application
|
I don't, it's simply an issue I ran into while migrating our code base. I think the problem I described in my last comment is quite serious as it's a common pattern to use methods like I just ran into this section in the trio documentation:
Maybe qtrio could wrap the execution of I hope this makes sense :) |
There's
I'll have to look more at the other bits to refresh myself. We might be able to check if the application is running at the end of every Trio callback into the Qt loop. |
So looking back at this, it appears that there is already a |
The warning is not always raised. Consider the example below: import trio
import qtrio
from PyQt5.QtWidgets import QApplication, QMainWindow
async def task(window):
await trio.sleep(1)
window.close()
QApplication.quit()
async def main():
try:
window = QMainWindow()
window.show()
async with trio.open_nursery() as nursery:
nursery.start_soon(task, window)
await trio.sleep(3)
finally:
print("Very important stuff!")
if __name__ == "__main__":
qtrio.run(main) See how |
Is it possible to monkeypatch |
apparently you can listen to aboutToQuit which runs after user input is disabled and before the event loop is closed |
Can you call The |
I'm not looking for a bunch of work right now so I wasn't going to take on actively keeping the loop going. Perhaps the monkey patching to disable quitting would be good, but I'm trying to muck around less, not more. Maybe later. For now I put in a warning triggered by |
Without agreeing to take it on now, it sounds like actually making sure everything runs in https://doc.qt.io/qt-5/qcoreapplication.html#exec
thanks for that... |
while you could in theory block in |
Hi @altendky,
When exiting our qtrio application (which runs with
qtrio.run
), we sometimes get the following warning:The comment here says something about garbage collection:
https://github.com/python-trio/trio/blob/3f4e1a23e567825926b225f87c64db56d95f96fb/trio/_core/_run.py#L2247-L2253
Do you have some ideas about what could cause this?
The text was updated successfully, but these errors were encountered: