128128< header >
129129 < h1 > < span class ="green "> gevent</ span > For the Working Python Developer</ h1 >
130130 < h3 class ="author ">
131- < a href =" http://www.stephendiehl.com " > Stephen Diehl </ a >
131+ Written by the Gevent Community
132132 </ h3 >
133133</ header >
134134
@@ -138,6 +138,10 @@ <h3 class="author">
138138
139139< div class ="toc ">
140140< ul >
141+ < li > < a href ="#introduction "> Introduction</ a > < ul >
142+ < li > < a href ="#contributors "> Contributors</ a > </ li >
143+ </ ul >
144+ </ li >
141145< li > < a href ="#core "> Core</ a > < ul >
142146< li > < a href ="#greenlets "> Greenlets</ a > </ li >
143147< li > < a href ="#synchronous-asynchronous-execution "> Synchronous & Asynchronous Execution</ a > </ li >
@@ -172,12 +176,27 @@ <h3 class="author">
172176</ li >
173177</ ul >
174178</ div >
175- < h1 id ="core " > Core </ h1 >
179+ < h1 id ="introduction " > Introduction </ h1 >
176180< p > The structure of this tutorial assumes an intermediate level
177181knowledge of Python but not much else. No knowledge of
178182concurrency is expected. The goal is to give you
179- the tools you need to get going with gevent and use it to solve
180- or speed up your applications today.</ p >
183+ the tools you need to get going with gevent, help you tame
184+ your existing concurrency problems and start writing asynchronous
185+ applications today.</ p >
186+ < h3 id ="contributors "> Contributors</ h3 >
187+ < p > In chronological order of contribution:
188+ < a href ="http://www.stephendiehl.com "> Stephen Diehl</ a >
189+ < a href ="https://github.com/jerem "> Jérémy Bethmont</ a >
190+ < a href ="https://github.com/sww "> sww</ a >
191+ < a href ="https://github.com/brunoqc "> Bruno Bigras</ a >
192+ < a href ="https://github.com/dripton "> David Ripton</ a >
193+ < a href ="https://github.com/traviscline "> Travis Cline</ a >
194+ < a href ="https://github.com/Lothiraldan "> Boris Feld</ a > </ p >
195+ < p > This is a collaborative document published under MIT license.
196+ Have something to add? See a typo? Fork and issue a
197+ pull request < a href ="https://github.com/sdiehl/gevent-tutorial "> Github</ a > .
198+ Any and all contributions are welcome.</ p >
199+ < h1 id ="core "> Core</ h1 >
181200< h2 id ="greenlets "> Greenlets</ h2 >
182201< p > The primary pattern used in gevent is the < strong > Greenlet</ strong > , a
183202lightweight coroutine provided to Python as a C extension module.
@@ -313,16 +332,16 @@ <h2 id="synchronous-asynchronous-execution">Synchronous & Asynchronous Execu
313332Task 8 done
314333Task 9 done
315334Asynchronous:
316- Task 3 done
317- Task 5 done
318- Task 4 done
319- Task 6 done
320335Task 0 done
321336Task 2 done
322- Task 8 done
337+ Task 6 done
338+ Task 5 done
339+ Task 3 done
340+ Task 4 done
341+ Task 9 done
323342Task 1 done
324343Task 7 done
325- Task 9 done
344+ Task 8 done
326345</ pre > </ code > </ p >
327346< p > In the synchronous case all the tasks are run sequentially,
328347which results in the main programming < em > blocking</ em > (
@@ -964,6 +983,7 @@ <h2 id="gevent-zeromq">Gevent ZeroMQ</h2>
964983gevent-zeromq</ code > </ p >
965984< pre > < code class ="python ">
966985# Note: Remember to ``pip install pyzmq gevent_zeromq``
986+ import gevent
967987from gevent_zeromq import zmq
968988
969989# Global Context
@@ -981,7 +1001,7 @@ <h2 id="gevent-zeromq">Gevent ZeroMQ</h2>
9811001
9821002def client():
9831003 client_socket = context.socket(zmq.REP)
984- client_socket.connect("tcp://* :5000")
1004+ client_socket.connect("tcp://127.0.0.1 :5000")
9851005
9861006 for request in range(1,10):
9871007
@@ -990,10 +1010,10 @@ <h2 id="gevent-zeromq">Gevent ZeroMQ</h2>
9901010 # Implicit context switch occurs here
9911011 client_socket.send("World")
9921012
993- publisher = gevent.spawn(server),
994- client = gevent.spawn(client),
1013+ publisher = gevent.spawn(server)
1014+ client = gevent.spawn(client)
9951015
996- gevent.joinall( publisher + client )
1016+ gevent.joinall([ publisher, client] )
9971017
9981018</ pre >
9991019
0 commit comments