Open altendky opened 5 years ago
It's a project I put together in my spare time to learn more about both Trio and the Qt event loop. It's not maintained and I used some slightly dirty tricks. It gets the job done, but it won't eat your CPU I don't think.
Is this something you're interested in using?
I presently work with Qt and Twisted and have interest in switching to Trio as at some point I've got a major rewrite coming anyways. I read through https://github.com/python-trio/trio/issues/399 once anyways, but should again. I haven't actually decided though if I can fit developing the Trio/Qt integration into my plans. I've got a lot I want to do differently. :[ But sure, there's some chance that one way or another I end up using this and contributing here or otherwise working on a solution.
It's worth giving a try. Trio is a great library. What I've whipped up here is likely the simplest solution, but I cannot say whether it is the best solution.
@henry232323 fwiw this definitely eats my CPU lol :smile_cat:
@goodboy Does it now? Whats your use case?
@henry232323 yessir. Have you tested for this before?
It makes sense too, a trio.sleep(0)
merely triggers a breakpoint in the trio
scheduler which in the idle case is essentially a noop. The only way I can see it not doing this is if the poll loop had blocking code or lots QT events to process that would mask the while
loop spinning.
Perhaps its worth inserting a brief normal sleep? Generally I would expect the trio event loop to handle a little downtime to avoid spinning the wheels, but its probably worth doing.
Do you have an explanation of what makes this only appropriate for use in desperate situations? Does it end up being more or less a full CPU usage busy loop with the
while True:
?