Debian Codegraph @

examples/eventlet/README.rst

raw
1 ==================================
2 Example using the Eventlet Pool
3 ==================================
4
5 Introduction
6 ============
7
8 This is a Celery application containing two example tasks.
9
10 First you need to install Eventlet, and also recommended is the `dnspython`
11 module (when this is installed all name lookups will be asynchronous)::
12
13 $ python -m pip install eventlet celery pybloom-live
14
15 Before you run any of the example tasks you need to start
16 the worker::
17
18 $ cd examples/eventlet
19 $ celery worker -l INFO --concurrency=500 --pool=eventlet
20
21 As usual you need to have RabbitMQ running, see the Celery getting started
22 guide if you haven't installed it yet.
23
24 Tasks
25 =====
26
27 * `tasks.urlopen`
28
29 This task simply makes a request opening the URL and returns the size
30 of the response body::
31
32 $ cd examples/eventlet
33 $ python
34 >>> from tasks import urlopen
35 >>> urlopen.delay('https://www.google.com/').get()
36 9980
37
38 To open several URLs at once you can do::
39
40 $ cd examples/eventlet
41 $ python
42 >>> from tasks import urlopen
43 >>> from celery import group
44 >>> result = group(urlopen.s(url)
45 ... for url in LIST_OF_URLS).apply_async()
46 >>> for incoming_result in result.iter_native():
47 ... print(incoming_result)
48
49 * `webcrawler.crawl`
50
51 This is a simple recursive web crawler. It will only crawl
52 URLs for the current host name. Please see comments in the
53 `webcrawler.py` file.