hgducharme / lichess-bot

A middle-man between your chess engine and lichess.com
GNU General Public License v3.0
1 stars 0 forks source link

`close_all_threads()` in shutdown sequence doesn't work #8

Closed hgducharme closed 1 year ago

hgducharme commented 1 year ago

When shutting down the CLI, the close_all_threads() function tells each thread to stop and then waits for them to clean themselves up. However, the function hangs waiting to hear back from the threads. Expected behavior: the threads report back saying they're done cleaning up and the CLI continues with shutdown, exiting gracefully.

hgducharme commented 1 year ago

Determined that the ChallengeStreamWatcher thread properly terminates, but the EventStreamWatcher is not terminating

hgducharme commented 1 year ago

What is happening is that the EventStreamWatcher is infinitely iterating over the event stream sent over by the lichess API. This is happening in the line for line in event_stream where event_stream is a python generator object, which is returned because we use response.iter_lines(stream = True) in the API call

hgducharme commented 1 year ago

Fixed (hopefully) with commit c63128f85785b6fc9a7710162abdd0c2c3601abe