@@ -250,43 +250,46 @@ def run(self, *, background_thread: bool = False):
250250 else :
251251 self ._running = True
252252 while self ._running and self .is_connected :
253- self ._running = self .handle_incoming_messages (blocking = True )
253+ self ._running , _ = self .handle_incoming_messages (blocking = True )
254254 self ._running = False
255255
256- def handle_incoming_messages (self , blocking : bool = False ) -> bool :
256+ def handle_incoming_messages (self , blocking : bool = False ) -> tuple [ bool , bool ] :
257257 """
258258 Empties queue of incoming messages (should be called regularly, see `run`).
259259 Optionally blocking, ensuring that at least one message will be handled.
260- Returns true message handling should continue running, and
260+
261+ First boolean returns true message handling should continue running, and
261262 false if RLBotServer has asked us to shut down or an error happened.
263+
264+ Second boolean returns true if there might be more messages to handle without a delay.
262265 """
263266 assert self .is_connected , "Connection has not been established"
264267 try :
265268 self .socket .setblocking (blocking )
266269 incoming_message = self .read_message ()
267270 try :
268- return self .handle_incoming_message (incoming_message )
271+ return self .handle_incoming_message (incoming_message ), True
269272 except flat .InvalidFlatbuffer as e :
270273 self .logger .error (
271274 "Error while unpacking message of type %s (%s bytes): %s" ,
272275 incoming_message .type .name ,
273276 len (incoming_message .data ),
274277 e ,
275278 )
276- return False
279+ return False , False
277280 except Exception as e :
278281 self .logger .error (
279282 "Unexpected error while handling message of type %s: %s" ,
280283 incoming_message .type .name ,
281284 e ,
282285 )
283- return False
286+ return False , False
284287 except BlockingIOError :
285288 # No incoming messages and blocking==False
286- return True
289+ return True , False
287290 except :
288291 self .logger .error ("SocketRelay disconnected unexpectedly!" )
289- return False
292+ return False , False
290293
291294 def handle_incoming_message (self , incoming_message : SocketMessage ):
292295 """
0 commit comments