| 1 |
<!doctype html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="UTF-8" /> |
| 5 |
<title>Eventlet Networking Library</title> |
| 6 |
<link rel="stylesheet" href="doc/_static/default.css" type="text/css" /> |
| 7 |
<link rel="stylesheet" href="doc/_static/pygments.css" type="text/css" /> |
| 8 |
<link rel="stylesheet" href="https://yandex.st/highlightjs/7.3/styles/default.min.css"> |
| 9 |
<link rel="top" title="Eventlet Networking Library" href="" /> |
| 10 |
</head> |
| 11 |
<body> |
| 12 |
<script> |
| 13 |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| 14 |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| 15 |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| 16 |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); |
| 17 |
|
| 18 |
ga('create', 'UA-42952223-1', 'eventlet.net'); |
| 19 |
ga('send', 'pageview'); |
| 20 |
</script> |
| 21 |
|
| 22 |
<div class="document"> |
| 23 |
<div class="documentwrapper"> |
| 24 |
<div class="bodywrapper"> |
| 25 |
<div class="body"> |
| 26 |
|
| 27 |
<div class="section" id="eventlet"> |
| 28 |
<h1>Eventlet</h1> |
| 29 |
|
| 30 |
<p>Eventlet is a concurrent networking library for Python that allows you to change how you run your code, not how you write it.</p> |
| 31 |
|
| 32 |
<ul> |
| 33 |
<li>It uses epoll or kqueue or libevent for <a class="reference external" target="_blank" href="http://en.wikipedia.org/wiki/Asynchronous_I/O#Select.28.2Fpoll.29_loops">highly scalable non-blocking I/O</a>.</li> |
| 34 |
<li><a class="reference external" target="_blank" href="http://en.wikipedia.org/wiki/Coroutine">Coroutines</a> ensure that the developer uses a blocking style of programming that is similar to threading, but provide the benefits of non-blocking I/O.</li> |
| 35 |
<li>The event dispatch is implicit, which means you can easily use Eventlet from the Python interpreter, or as a small part of a larger application.</li> |
| 36 |
</ul> |
| 37 |
|
| 38 |
<p>It's easy to get started using Eventlet, and easy to convert existing applications to use it. Start off by looking at <a href="doc/examples.html">examples</a>, <a href="doc/design_patterns.html">common design patterns</a>, and the list of the <a href="doc/basic_usage.html">basic API primitives</a>.</p> |
| 39 |
|
| 40 |
<p>License: <a class="reference external" target="_blank" href="https://opensource.org/licenses/MIT">MIT</a></p> |
| 41 |
|
| 42 |
<p>Currently supporting CPython 3.7+.</p> |
| 43 |
|
| 44 |
<h3><a href="doc/">API Documentation</a></h3> |
| 45 |
|
| 46 |
|
| 47 |
<h3>Installation</h3> |
| 48 |
|
| 49 |
<ul> |
| 50 |
<li><p>To install latest PyPI release: |
| 51 |
<code><pre>pip install eventlet</pre></code> |
| 52 |
</p> |
| 53 |
<p>Manually lock version in requirements, if your build/development process doesn't automate it: |
| 54 |
<code><pre># requirements.txt |
| 55 |
eventlet==x.y</pre></code></p> |
| 56 |
</li> |
| 57 |
|
| 58 |
<li><p>Eventlet team is commited to have only stable code in master branch, so recommended way to install is from latest master commit: |
| 59 |
<code><pre>pip install https://github.com/eventlet/eventlet/archive/master.zip</pre></code> |
| 60 |
</p> |
| 61 |
<p>Beware, http…zip link in requirements.txt will repeat download and installation even if you specify link to particular commit.</p> |
| 62 |
</li> |
| 63 |
|
| 64 |
<li><p>Earlier versions available at <a class="reference external" target="_blank" href="https://pypi.org/project/eventlet/">Eventlet on PyPI</a> |
| 65 |
</p> |
| 66 |
</li> |
| 67 |
</ul> |
| 68 |
|
| 69 |
|
| 70 |
<h3>Development</h3> |
| 71 |
|
| 72 |
<p>Development, issue tracking happens at <a class="reference" target="_blank" href="https://github.com/eventlet/eventlet/">Eventlet on Github</a></p> |
| 73 |
<p>We had <a class="reference external" target="_blank" href="https://bitbucket.org/eventlet/eventlet/">Mercurial repository on Bitbucket</a>, but it's not used anymore.</p> |
| 74 |
|
| 75 |
<h4>Pull request policy</h4> |
| 76 |
<ul> |
| 77 |
<li>Test is required</li> |
| 78 |
<li>One commit is strongly preferred, except for very big changes</li> |
| 79 |
<li>Commit message should follow the following formula: |
| 80 |
<pre> |
| 81 |
subsystem: description of why the change is useful |
| 82 |
|
| 83 |
optional details |
| 84 |
|
| 85 |
links to related issues or websites |
| 86 |
</pre> |
| 87 |
The <em>why</em> part is very important. Diff already says <em>what</em> you have done. But nobody knows why. |
| 88 |
</li> |
| 89 |
<li>Feel free to append yourself into AUTHORS file, sections Thanks To or Contributors. |
| 90 |
</ul> |
| 91 |
<p>If you don't like these rules, raw patches are more than welcome!</p> |
| 92 |
|
| 93 |
|
| 94 |
<h4>Bugs</h4> |
| 95 |
|
| 96 |
<p>Please be sure to report bugs <a class="reference external" target="_blank" href="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html">as effectively as possible</a>, to ensure that we understand and act on them quickly.</p> |
| 97 |
|
| 98 |
<p>Usually <a class="reference external" target="_blank" href="https://github.com/eventlet/eventlet/issues/new">open issue at Github</a></p> |
| 99 |
|
| 100 |
<p>In special cases, to contact current maintainers directly, look up info on Github project page.</p> |
| 101 |
|
| 102 |
|
| 103 |
<div class="section" id="web-crawler-example"> |
| 104 |
<h2>Web Crawler Example<a class="headerlink" href="#web-crawler-example" title="Permalink to this headline">¶</a></h2> |
| 105 |
<p>This is a simple web “crawler” that fetches a bunch of urls using a coroutine pool. It has as much concurrency (i.e. pages being fetched simultaneously) as coroutines in the pool.</p> |
| 106 |
|
| 107 |
<pre><code class="language-python">import eventlet |
| 108 |
# note: this urllib import doesn't work in Python2 |
| 109 |
from eventlet.green.urllib.request import urlopen |
| 110 |
|
| 111 |
|
| 112 |
urls = [ |
| 113 |
"http://www.google.com/intl/en_ALL/images/logo.gif", |
| 114 |
"https://wiki.secondlife.com/w/images/secondlife.jpg", |
| 115 |
"http://us.i1.yimg.com/us.yimg.com/i/ww/beta/y3.gif", |
| 116 |
] |
| 117 |
|
| 118 |
|
| 119 |
def fetch(url): |
| 120 |
return urlopen(url).read() |
| 121 |
|
| 122 |
|
| 123 |
pool = eventlet.GreenPool() |
| 124 |
|
| 125 |
for body in pool.imap(fetch, urls): |
| 126 |
print("got body", len(body)) |
| 127 |
</code></pre> |
| 128 |
|
| 129 |
|
| 130 |
<h3>Flair</h3> |
| 131 |
<p> |
| 132 |
<a class="reference external" target="_blank" href="https://pypi.org/project/eventlet/" rel="nofollow"><img alt="PyPI" src="https://img.shields.io/pypi/v/eventlet"></a> |
| 133 |
<a class="reference external" target="_blank" href="https://travis-ci.org/eventlet/eventlet" rel="nofollow"><img alt="Travis build" src="https://travis-ci.org/eventlet/eventlet.svg?branch=master"></a> |
| 134 |
<a class="reference external" target="_blank" href="https://codecov.io/gh/eventlet/eventlet" rel="nofollow"><img alt="Codecov coverage" src="https://codecov.io/gh/eventlet/eventlet/branch/master/graph/badge.svg?token=k01TsER6fy"></a> |
| 135 |
</p> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
</div> |
| 139 |
|
| 140 |
|
| 141 |
<div class="section" id="contents"> |
| 142 |
</div> |
| 143 |
</div> |
| 144 |
</div> |
| 145 |
</div> |
| 146 |
<div class="sphinxsidebar"> |
| 147 |
<div class="sphinxsidebarwrapper"> |
| 148 |
<h3>Links</h3> |
| 149 |
<ul> |
| 150 |
<li><a class="reference external" href="doc/">Documentation</a></li> |
| 151 |
<li><a class="reference external" href="doc/changelog.html">Changelog</a></li> |
| 152 |
<li><a class="reference external" target="_blank" href="https://github.com/eventlet/eventlet/">Eventlet on Github</a></li> |
| 153 |
<li><a class="reference external" target="_blank" href="irc://chat.freenode.net/#eventlet">IRC channel</a></li> |
| 154 |
<li><a class="reference external" target="_blank" href="https://www.openhub.net/p/eventlet">Open Hub stats</a></li> |
| 155 |
</ul> |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
<script src="//yandex.st/highlightjs/7.3/highlight.min.js"></script> |
| 160 |
<script>hljs.initHighlightingOnLoad();</script> |
| 161 |
</body> |
| 162 |
</html> |