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

nflgame.live run with Threading #80

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

nflgame.live run with Threading #80

wants to merge 5 commits into from

Conversation

tkutcher
Copy link

@tkutcher tkutcher commented Sep 4, 2019

See #78

Changes

  • stop_event parameter added to run() in nflgame.live
  • LiveRunner class to call run in a thread, with a shutdown() method to shutdown gracefully

Notes

  • Didn't exactly test it / not sure how to test it (other than waiting for live games then just manually checking some debugging logs)
  • Refactored some of the logic using ternary operator (if that's against typical style I'll take it out)
    • Also left a TODO comment in that can do the same thing the if-else above it.
  • Another thought that could clean up the code is if a stop_date is provided, just set a timer that sets the stop_event. e.g.
if stop_date is not None:
    wait_time = # some expression
    t = threading.Timer(wait_time, lambda: stop_event.set())

@derek-adair
Copy link
Owner

This component was in "alpha status" so there is a pretty low barrier to entry to modify this one. As far as i can tell testing this would require some sophisticated mocks that create game(s) in the past, present and future, with some kind of "time traveling" that adjusts the time. Not sure what that would look like.

@tkutcher
Copy link
Author

tkutcher commented Sep 7, 2019

Got it - I'll mark as ready!

@tkutcher tkutcher marked this pull request as ready for review September 7, 2019 15:18
@derek-adair
Copy link
Owner

Good work, i'll be testing this locally tomorrow.

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

Successfully merging this pull request may close these issues.

2 participants