Recently, our team has been moving from C++ (VEXcode pro V5), over to the python platform offered by VEXcode V5.
In the past we have been using:
vex::task::yield();
to ensure control is passed between our many vex::task objects and threads while wasting as little time as possible.
The closest thing I have found in python is this:
wait(20, MSEC)
# Not necessarily 20 msecs, but you get the idea.
while this is an option, I would prefer a solution that doesn’t force the thread (or task) to wait the specified amount. Rather, something that allows as little time as possible to be “wasted” between times of control returned to the scheduler.
Desired functionality example:
def some_thread_callback():
while True:
# Do something
yield()
# Not to be confused with the built in 'yield' keyword for python generators
thread = Thread(some_thread_callback)
# main loop
while True:
# Do something
yield()
where each ’ yield() ’ would behave like vex::task::yield() found from C++, as seen below:
Thanks in advance for any help offered.