Skip to content

Instantly share code, notes, and snippets.

@AlexDel
Created July 29, 2020 10:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AlexDel/b96a0c028efdf1de841d777795b5cc5e to your computer and use it in GitHub Desktop.
How to make concurent delya with rx.py
!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