timraay / HLLLogUtilities

A Discord bot that makes it easy to capture and export logs from your HLL servers
MIT License
9 stars 6 forks source link

Automatically wait for more packets to accumulate if array is incomplete #11

Closed timraay closed 1 year ago

timraay commented 1 year ago

There are some odd instances where the get playerids command fails because it's incomplete. We could flag the request with multipart=True, however ideally I'd want to get this specific operation over with as soon as possible. It would be much more efficient to wait only when the array is still incomplete.

So essentially, make the unpack_array=True flag use the same logic as multipart=True, but make it exit when the array is complete instead of when no more packets are being accumulated.

[2022-12-04 21:28:08,151][ERROR][rcon.wrapper:81] Missed 1 consecutive updates for <lib.rcon.HLLRcon object at 0x000002A360972020>, 19 attempts left
Traceback (most recent call last):
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\rcon.py", line 78, in wrapper
    res = await asyncio.wait_for(func(self, *args, **kwargs), timeout=10)
  File "C:\Users\abusify\AppData\Local\Programs\Python\Python310\Lib\asyncio\tasks.py", line 445, in wait_for
    return fut.result()
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\rcon.py", line 155, in update
    await self._fetch_server_info()
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\rcon.py", line 161, in _fetch_server_info
    res = await asyncio.gather(
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\rcon.py", line 275, in __fetch_current_server_info
    map, playerids = await asyncio.gather(
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\rcon.py", line 254, in exec_command
    res = await fut
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\rcon.py", line 747, in _worker
    res = await self.protocol.execute(cmd, **kwargs)
  File "C:\Users\abusify\Documents\Python\HLLLogUtilities\lib\protocol.py", line 123, in execute
    raise HLLUnpackError("Expected array size %s but got %s", arr_size, len(res))
lib.exceptions.HLLUnpackError: ('Expected array size %s but got %s', 99, 45)