[ros-users] rospy.sleep() blocking callbacks
Cedric Pradalier
cedric.pradalier at mavt.ethz.ch
Wed Jul 7 05:47:44 UTC 2010
On 07/07/2010 12:05 AM, Dan Lazewatsky wrote:
> I'm writing on a GUI in Python/Tk - I have a subscriber which is
> listening for image messages and setting a class member variable with
> the newest image, and a GUI element that needs to use image (after
> sending a message to move a pan/tilt). On click I use rospy.sleep() to
> wait for the pan/tilt to settle down before using any images. However,
> I've noticed that once I call rospy.sleep() inside the click callback,
> the callback for the image subscriber stops getting called. It was my
> understanding that subscriber callbacks are run asynchronously in
> their own thread, so a sleep in a different thread should have no
> effect. What's going on here? What am I missing?
>
> Thanks,
> -Dan
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
Hi Dan,
Python is sometimes counter-intuitive with his management of threads,
leading sometimes to some global lock where one thread blocks everything.
I'd suggest keeping your in-callback time to a minimum, maybe just
triggering another thread which will do the waiting (or switch to C++,
with real threads).
HTH
--
Cedric - Specialising in cat herding
- http://www.asl.ethz.ch/people/cedricp
- http://www.skybotix.com
More information about the ros-users
mailing list