As a part of a project, I am working on a client that sends UDP packets in a certain beat (messages per second) that I take as an input.
My Windows machine can send up to ~30K messages per second, so let's say I need to send 4K messages per second, I can calculate the delay I need to put between each message so I will send approximately the requested amount in each second, and set the delay by using time.sleep()
.
My problem is that when I get an amount like 27K messages per second, which is really close to the max amount of messages per second, the delay between each message is in micro-seconds, which time.sleep()
is not accurate in that unit.
Is there any other way to delay micro-seconds in python?
EDIT- time.sleep()
is not accurate in micro-seconds, I need the delay to be accurate