Created
July 29, 2020 10:36
-
-
Save AlexDel/b96a0c028efdf1de841d777795b5cc5e to your computer and use it in GitHub Desktop.
How to make concurent delya with rx.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!pip install rx | |
import time | |
import rx | |
from rx import operators as ops | |
PLEASE_WAIT_TIMEOUT = 2 | |
SEARCH_TIMEOUT = 3 | |
def utter_bot(): | |
print('Please wait') | |
def search(): | |
time.sleep(SEARCH_TIMEOUT) | |
print('have results') | |
return [] | |
res = rx.timer(PLEASE_WAIT_TIMEOUT).pipe( | |
ops.do_action(on_next=lambda _: utter_bot()) | |
) | |
subscription = res.subscribe() | |
search() | |
subscription.dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment