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

Add timeout parameter while waiting for events #202

Closed
3 of 4 tasks
illume opened this issue Jun 7, 2014 · 8 comments
Closed
3 of 4 tasks

Add timeout parameter while waiting for events #202

illume opened this issue Jun 7, 2014 · 8 comments
Assignees
Labels
easy An easy challenge to solve enhancement event pygame.event minor

Comments

@illume
Copy link
Member

illume commented Jun 7, 2014

Originally reported by: metagriffin (Bitbucket: metagriffin, GitHub: metagriffin)


i think it would be great if the wait functions (pygame.event.wait and pygame.fastevent.wait) could accept a timeout parameter -- this would alleviate the need to duplicate a lot of code that uses the poll/sleep approach to reduce CPU consumption.


To Do to resolve:

  • Add timeout parameter to pygame.event.wait() after which time it will return True even if the event has not yet occurred.
  • Add timeout parameter to pygame.fastevent.wait() after which time it will return True even if the event has not yet occurred.
  • Add unit tests for these new functions.
  • Update the docs.

Related Docs: https://www.pygame.org/docs/ref/event.html#pygame.event.wait

@illume
Copy link
Member Author

illume commented Jun 7, 2014

Original comment by metagriffin (Bitbucket: metagriffin, GitHub: metagriffin):


i created a pull request #31 to provide an implementation.

@MyreMylar
Copy link
Contributor

MyreMylar commented Apr 29, 2020

I've linked the original pull request for this since the #31 link above actually points to an unrelated bug on github:

https://bitbucket.org/pygame/pygame/pull-requests/31/add-timeout-parameter-while-waiting-for/diff

I'm still a little lost on the use cases myself, even after reading the bitbucket thread.

@MyreMylar MyreMylar added the easy An easy challenge to solve label May 16, 2020
@MyreMylar
Copy link
Contributor

MyreMylar commented May 16, 2020

This was started back on bitbucket with the use case suggested of a clock that updates the screen when a hand moves or, I guess, when the user prods it some way.

@MyreMylar MyreMylar changed the title add timeout parameter while waiting for events Add timeout parameter while waiting for events May 16, 2020
@nthykier
Copy link
Contributor

nthykier commented Jun 1, 2020

Wouldn't it be better (more reliable/simpler) to use a timer for this?

@MyreMylar
Copy link
Contributor

We now have a timeout parameter for event.wait() so just need one for the equivelent fastevent.wait()

@ankith26
Copy link
Contributor

I’ll probably try adding the timeout parameter to the fastevent.wait method

@ankith26 ankith26 self-assigned this Nov 10, 2020
@illume
Copy link
Member Author

illume commented Nov 10, 2020

I'm not sure if fastevent is relevant anymore on SDL2. I'm pretty sure the new event loop is very fast with mulitple threads posting now... but haven't confirmed.

@ankith26
Copy link
Contributor

Hmm, so close this issue?
I’m just trying to get the issue count to under 200 :)

@illume illume closed this as completed Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy An easy challenge to solve enhancement event pygame.event minor
Projects
None yet
Development

No branches or pull requests

4 participants