mirror of https://github.com/rq/rq.git
Simplify the count_words_at_url example.
The long implementation derived attention a bit from the actual point of enqueuing here.
This commit is contained in:
parent
9986fee00e
commit
abc66171eb
12
README.md
12
README.md
|
@ -15,17 +15,11 @@ First, run a Redis server, of course:
|
||||||
To put jobs on queues, you don't have to do anything special, just define
|
To put jobs on queues, you don't have to do anything special, just define
|
||||||
your typically lengthy or blocking function:
|
your typically lengthy or blocking function:
|
||||||
|
|
||||||
import urllib2
|
import requests
|
||||||
|
|
||||||
def count_words_at_url(url):
|
def count_words_at_url(url):
|
||||||
f = urllib2.urlopen(url)
|
resp = requests.get(url)
|
||||||
count = 0
|
return len(resp.text.split())
|
||||||
while True:
|
|
||||||
line = f.readline()
|
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
count += len(line.split())
|
|
||||||
return count
|
|
||||||
|
|
||||||
Then, create a RQ queue:
|
Then, create a RQ queue:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue