Search code examples
pythonpython-3.xmultithreadingpython-multithreadingethernet

Is it possible to activate a thread every 1us with python?


For my application, a need a function that records an Ethernet Frame every 1us. Is it possible to do it with python/threading ?

The maximum delay I got with threading.Timer is close to 10ms.


Solution

  • No.

    1µs is well below the the granularity regular operating systems offer, which is usually measured in milliseconds (i.e. thousands of µs). See this answer for a discussion about Linux time slices as well as this one.

    Needless to say, if the operating system cannot offer such granularity, then there's no hope for anything running in user space.

    If you actually need µs level precision, you need to be looking at real-time systems. And since you have the ethernet tag in your question, you might also want to look at network processors.