@@ -133,7 +133,7 @@ <h3 class="author">
133133</ header >
134134
135135< blockquote >
136- gevent is a concurrency library based around libev. It provides a clean API for a variety of concurrency and network related tasks.
136+ gevent is a concurrency library based around < a href =" http://software.schmorp.de/pkg/ libev.html " > libev </ a > . It provides a clean API for a variety of concurrency and network related tasks.
137137</ blockquote >
138138
139139< div class ="toc ">
@@ -171,7 +171,6 @@ <h3 class="author">
171171< li > < a href ="#long-polling "> Long Polling</ a > </ li >
172172< li > < a href ="#websockets "> Websockets</ a > </ li >
173173< li > < a href ="#chat-server "> Chat Server</ a > </ li >
174- < li > < a href ="#license "> License</ a > </ li >
175174</ ul >
176175</ li >
177176</ ul >
@@ -191,7 +190,9 @@ <h3 id="contributors">Contributors</h3>
191190< a href ="https://github.com/brunoqc "> Bruno Bigras</ a >
192191< a href ="https://github.com/dripton "> David Ripton</ a >
193192< a href ="https://github.com/traviscline "> Travis Cline</ a >
194- < a href ="https://github.com/Lothiraldan "> Boris Feld</ a > </ p >
193+ < a href ="https://github.com/Lothiraldan "> Boris Feld</ a >
194+ < a href ="https://github.com/youngsterxyf "> youngsterxyf</ a >
195+ < a href ="https://github.com/ehebert "> Eddie Hebert</ a > </ p >
195196< p > This is a collaborative document published under MIT license.
196197Have something to add? See a typo? Fork and issue a
197198pull request < a href ="https://github.com/sdiehl/gevent-tutorial "> Github</ a > .
@@ -203,7 +204,7 @@ <h2 id="greenlets">Greenlets</h2>
203204Greenlets all run inside of the OS process for the main
204205program but are scheduled cooperatively. This differs from any of
205206the real parallelism constructs provided by < code > multiprocessing</ code > or
206- < code > multithreading</ code > libraries which do spin processes and posix threads
207+ < code > multithreading</ code > libraries which do spin processes and POSIX threads
207208which are truly parallel.</ p >
208209< h2 id ="synchronous-asynchronous-execution "> Synchronous & Asynchronous Execution</ h2 >
209210< p > The core idea of concurrency is that a larger task can be broken
@@ -336,16 +337,16 @@ <h2 id="synchronous-asynchronous-execution">Synchronous & Asynchronous Execu
336337Task 8 done
337338Task 9 done
338339Asynchronous:
340+ Task 6 done
339341Task 0 done
340- Task 2 done
341342Task 5 done
343+ Task 3 done
344+ Task 8 done
345+ Task 2 done
346+ Task 4 done
342347Task 7 done
343348Task 1 done
344- Task 3 done
345- Task 6 done
346349Task 9 done
347- Task 4 done
348- Task 8 done
349350</ pre > </ code > </ p >
350351< p > In the synchronous case all the tasks are run sequentially,
351352which results in the main programming < em > blocking</ em > (
@@ -451,8 +452,8 @@ <h2 id="determinism">Determinism</h2>
451452non-determinism can creep into your program when you beging to
452453interact with outside services such as sockets and files. Thus
453454even though green threads are a form of "deterministic
454- concurrency", they still can experience some of the smae problems
455- that posix threads and processes experience.</ p >
455+ concurrency", they still can experience some of the same problems
456+ that POSIX threads and processes experience.</ p >
456457< p > The perennial problem involved with concurrency is known as a
457458< em > race condition</ em > . Simply put is when two concurrent threads
458459/ processes depend on some shared resource but also attempt to
@@ -621,6 +622,7 @@ <h2 id="timeouts">Timeouts</h2>
621622Greenlet.</ p >
622623< pre >
623624< code class ="python ">
625+ import gevent
624626from gevent import Timeout
625627
626628seconds = 10
@@ -995,7 +997,7 @@ <h2 id="gevent-zeromq">Gevent ZeroMQ</h2>
995997
996998def server():
997999 server_socket = context.socket(zmq.REQ)
998- server_socket.bind("tcp://* :5000")
1000+ server_socket.bind("tcp://127.0.0.1 :5000")
9991001
10001002 for request in range(1,10):
10011003 server_socket.send("Hello")
@@ -1143,8 +1145,10 @@ <h2 id="wsgi-servers">WSGI Servers</h2>
11431145
11441146< h2 id ="long-polling "> Long Polling</ h2 >
11451147< pre >
1146- < code class ="python "> from gevent.queue import Queue, Empty
1148+ < code class ="python "> import gevent
1149+ from gevent.queue import Queue, Empty
11471150from gevent.pywsgi import WSGIServer
1151+ import simplejson as json
11481152
11491153data_source = Queue()
11501154
@@ -1335,10 +1339,6 @@ <h2 id="chat-server">Chat Server</h2>
13351339 http.serve_forever()
13361340</ code >
13371341</ pre >
1338-
1339- < h2 id ="license "> License</ h2 >
1340- < p > This is a collaborative document published under MIT license. Forking
1341- on < a href ="https://github.com/sdiehl/gevent-tutorial "> GitHub</ a > is encouraged</ p >
13421342</ div >
13431343</ body >
13441344</ html >
0 commit comments