Python terminal slows down over time

Hi everyone,

I’m using an odrive as part of a larger system that is being coordinated via a python program run from an ipython terminal. This system will often run for a few hours at a time, over which the terminal + all running code slows down (even typing letters/print statements take ~1-2 seconds to execute). I’ve found that if I destroy the odrive object, after about 30 seconds the terminal will go back to its original speed.

I don’t think this is a memory leak, as the total memory usage of my terminal doesn’t change over time. I have a ferrite bead at either end of the usb cable, and I am not going through a usb hub.

Thanks in advance for any suggestions!



I think I found a fix, though it would be great if someone who knows better could explain why this works.

odrv0._libfibre.timer_map is a dictionary that adds a new <TimerHandle> entry once per second. As these entries accumulate, the terminal eventually slows down. I assume these are all involved in some background process within libfibre that accumulate into GIL. When i clear this dictionary by odrv0._libfibre.timer_map = {}, in a second or two (assuming this is the interval of the libfibre background process) the terminal speed goes back to normal. From what I can tell this does not affect operation of the odrive.


Thanks for tracking down the issue. Can you try the following fix in (if you installed odrive via pip the location of this file depends on your OS)

copy&paste from here:

        def cb():
        timer_id = insert_with_new_id(self.timer_map, self.loop.call_later(delay, cb))

Think this bug only manifests on Windows so I didn’t have time to test the fix yet.

I am having the same problem. I have stared at the code for hours and the copy and paste appears to be identical to the original. Am I missing something?