You will have to give a complete description of your project including what is being driven by the L298 and the reasoning behind the maniac transfer.
Only because your python code is sending it like a maniac. Either slow it down or implement a protocol.
Simple protocol
- Python send message and waits for acknowledge.
- Arduino receives and sends acknowledge back.
- Back to (1).
And read Robin's updated serial input basics topic.