Retry retries a specific function with the given frequency.
A context with timeout or deadline can be passed to set a timeout.
The passed function will be retried until it either returns no error, or a timeout happens.
An error is only returned by this function if a timeout happened.