So after going through the entire Redis implementation code of SerpentAI I believe I have found the answer, though it just confuses me more and require more clarification.
The issue it turns out is that I run the following code in my game agent init function:
self.game_frame_buffer = FrameGrabber.get_frames(
[0, 1, 2, 3],
I run this call to get a sample frame to get window dimensions and avoid hard coding values in my code. This works after initially setting up a new environment from scratch, but after I flush the Redis database using the command below the code above never completes.
The reason it turns out is that unfortunately, the first thing the get_frames function in frame_grabber does is execute a while loop as shown below:
if redis_client.llen(config["frame_grabber"]["redis_key"]) > 149:
This code checks if Redis has gathered enough frames to fill it’s internal buffer of frames before getting any frames. This would be fine, except, unless I have disabled it somehow, there does not seem to be any other process running to fill the buffer with frames while my game agent is initializing. So since I flushed the Redis database it needs to be filled with new frames, and this is not done before I call FrameGrabber.get_frames, and as such the code loops forever in an endless while true loop.
The manual fix is that every time I flush Redis database I now run serpent to capture frames until I have cached more than 150 frames in Redis, but this is a clunky and confusing. It would be better design to ensure Redis database is filled with frames while the loop is going.
The call to fill Redis database manually is:
serpent capture frame <game_name> 0.5
The last number is how often you want to capture a frame, and since default fps from SerpentAI is 2 fps, going lower than 0.5 seems to have no effect.