Created
June 11, 2020 07:12
-
-
Save velotiotech/ddcabb504e11b18882ddfbcf73c66d1e to your computer and use it in GitHub Desktop.
asyc using rq
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
from mymodule import count_words_at_url | |
from redis import Redis | |
from rq import Queue | |
q = Queue(connection=Redis()) | |
job = q.enqueue(count_words_at_url, 'http://nvie.com') | |
******mymodule.py****** | |
import requests | |
def count_words_at_url(url): | |
"""Just an example function that's called async.""" | |
resp = requests.get(url) | |
print( len(resp.text.split())) | |
return( len(resp.text.split())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment