The problem is to emulate the double looping behavior with RX:
while True:
try:
token = get_token()
while True:
try:
value = get_value_using_token(token)
do_something(value)
except:
break
except:
break
It would be clean if the two loops are replaced with two observables, one acting as an observer of the outer one, while do_something(value)
can be replaced with an observer on its own. Any exceptions can be handled nicely as well. Outer loop needs to be blocking, but inner loop may not be, as I am trying to use outer loop to handle exceptions using retry function with a backoff function.
So far I can build a sequence using:
Observable.from_iterable(value for value in iter(get_token, None))
.subscribe(do_something)
but how can I make a similar structure in blocking mode for the outer?