Audience
Anyone seeking a solution to manage waiting times for a function to return True, in various modes
About waiting
waiting is a small library for waiting for stuff to happen. It basically waits for a function to return True, in various modes. Waiting is compatible with flux for simulated timelines. The most basic usage is when you have a function you want to wait for. Waiting forever is very simple. If your predicate returns a value, it will be returned as the result of wait(). A timeout parameter can also be specified. When a timeout expires without the predicate being fulfilled, an exception is thrown. Sleeping polls the predicate at a certain interval (by default 1 second). The interval can be changed with the sleep_seconds argument. When waiting for multiple predicates, waiting provides two simple facilities to help aggregate them, any and all. They resemble Python’s built-in any() and all(), except that they don’t call a predicate once it has been satisfied (this is useful when the predicates are inefficient and take time to complete).