I want to write a Python program that waits some arbitrary time into the future (e.g. the time 500 milliseconds from now) and do something. I have a C++ code that does this fine using the Chrono library, so how can I do this in Python? I need accuracy of higher than 50 milliseconds (important) which this C++ code provides.
I do not want time.sleep(), I want a specific time_point in the future to sleep to and not a duration because I want to sync multiple threads to the same time.
int main() {
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
// get time 500 ms from now
steady_clock::time_point next_frame = steady_clock::now() + std::chrono::milliseconds(500);
std::thread t1{takeImages, next_frame};
std::thread t2{takeImages, next_frame};
}
void takeImages(steady_clock::time_point next_frame)
{
std::this_thread::sleep_until(next_frame);
//do something here
}