Skip to content
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

Support asyncio delayed calls in framerate_regulator #33

Open
rm-hull opened this issue Feb 27, 2017 · 2 comments
Open

Support asyncio delayed calls in framerate_regulator #33

rm-hull opened this issue Feb 27, 2017 · 2 comments

Comments

@rm-hull
Copy link
Owner

rm-hull commented Feb 27, 2017

Add capability wait in event loops rather than relying on time.sleep(...).

ref: https://docs.python.org/3/library/asyncio-eventloop.html#delayed-calls

@dhrone
Copy link
Collaborator

dhrone commented Sep 12, 2020

I've been thinking about this request and I'm not sure Asyncio is a good candidate for this use case. You are only going to have in-effect two co-routines, one producing images and the other consuming. If the time to paint the screen is a substantial component of the duration of the period of a frame, you'll have left your generating co-routine with little time to generate the next frame.

Given the simple communications model here
Generator -> display

I would propose introducing a queue and placing the display inside an OS thread.

Generator -> queue -> separate_thread(display)

As we will only be spinning up one thread it should not be a major resource hit and the queue makes sending the data to the display thread-safe.

As long as the generator can place new images in the queue faster than the frame rate (and assuming the time to refresh the display is lower than the frame rate) you should be able to get efficient resource sharing without typical multi-threaded headaches..

I also have some code I can pull in which uses a PID algorithm to smooth timing loops like this.

Let me know your thoughts.

Cheers!

@rm-hull
Copy link
Owner Author

rm-hull commented Sep 20, 2020

I think the original motivation for this was to support an alternative programming model (asyncio) rather than for performance reasons, but i didn't put sufficient detail in the ticket...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants