Using speedl and stopl from RTDE Interface

Hello UR community,

I am using RTDE interface to send speedL command to UR 5e. I do some processing for some time and then send stopL command. Example code:

But I keep getting the error “Another thread is controlling the robot”.

Please suggest a solution.

Thank you,
AkGr