Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/ddcabb504e11b18882ddfbcf73c66d1e to your computer and use it in GitHub Desktop.
Save velotiotech/ddcabb504e11b18882ddfbcf73c66d1e to your computer and use it in GitHub Desktop.
asyc using rq
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