I have while loop for get packets
unpackedData = struct.unpack("!BBHHHBBH4s4sHH4s4s4sHH4s", data[:44])
this line throws exception
Unpack requires a string argument of length 44 python
But after using debugger i noticed that it happens after few loops, I think its because cache is filled.
Is there any way to clear python cache or destroy objects or something like that?
My best guess is that in your while loop, you’re shortening the
datastring each time by 44 characters, however, 44 doesn’t divide your original string evenly so at the last iteration you’re left with a piece of the string that is less than 44 characters long.python doesn’t complain about the slicing, it just returns a string which is smaller than you expect. e.g.: