def extract_state(status): state = status['state'] task.state = state if state == 'FAILED': return throw(ee.EEException(status.get('error_message'))) else: return of(state)
def file_with_path( credentials, path: str, retries: int = 5 ) -> Observable: return _files_in_path(credentials, path, retries).pipe( last(), flat_map(lambda file: of(file) if file else throw(Exception('File {} does not exist.'.format(path)))), )
def do_retry(source, tries, exception): if tries <= retries: logging.warning( 'retry_with_backoff(tries={}, retries={}, exception={}, description={})'.format( tries, retries, exception, description )) return of(None).pipe( delay(backoff(tries), TimeoutScheduler.singleton()), flat_map(source), catch(handler=lambda e, src: do_retry(src, tries + 1, e)) ) else: return throw(exception)
def throw_if_error(r): if error: return throw(error) else: return of(r)