henry232323 / triqt

Run the Qt event loop from within the Trio event loop
BSD 2-Clause "Simplified" License
6 stars 1 forks source link

Why is this desperation-ware? #3

Open altendky opened 5 years ago

altendky commented 5 years ago

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:?

henry232323 commented 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.

henry232323 commented 5 years ago

Is this something you're interested in using?

altendky commented 5 years ago

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.

henry232323 commented 5 years ago

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.

goodboy commented 4 years ago

@henry232323 fwiw this definitely eats my CPU lol :smile_cat:

henry232323 commented 4 years ago

@goodboy Does it now? Whats your use case?

goodboy commented 4 years ago

@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.

henry232323 commented 4 years ago

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.