@@ -133,7 +133,7 @@ <h3 class="author">
133
133
</ header >
134
134
135
135
< 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.
137
137
</ blockquote >
138
138
139
139
< div class ="toc ">
@@ -171,7 +171,6 @@ <h3 class="author">
171
171
< li > < a href ="#long-polling "> Long Polling</ a > </ li >
172
172
< li > < a href ="#websockets "> Websockets</ a > </ li >
173
173
< li > < a href ="#chat-server "> Chat Server</ a > </ li >
174
- < li > < a href ="#license "> License</ a > </ li >
175
174
</ ul >
176
175
</ li >
177
176
</ ul >
@@ -191,7 +190,9 @@ <h3 id="contributors">Contributors</h3>
191
190
< a href ="https://github.com/brunoqc "> Bruno Bigras</ a >
192
191
< a href ="https://github.com/dripton "> David Ripton</ a >
193
192
< 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 >
195
196
< p > This is a collaborative document published under MIT license.
196
197
Have something to add? See a typo? Fork and issue a
197
198
pull request < a href ="https://github.com/sdiehl/gevent-tutorial "> Github</ a > .
@@ -203,7 +204,7 @@ <h2 id="greenlets">Greenlets</h2>
203
204
Greenlets all run inside of the OS process for the main
204
205
program but are scheduled cooperatively. This differs from any of
205
206
the 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
207
208
which are truly parallel.</ p >
208
209
< h2 id ="synchronous-asynchronous-execution "> Synchronous & Asynchronous Execution</ h2 >
209
210
< 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
336
337
Task 8 done
337
338
Task 9 done
338
339
Asynchronous:
340
+ Task 6 done
339
341
Task 0 done
340
- Task 2 done
341
342
Task 5 done
343
+ Task 3 done
344
+ Task 8 done
345
+ Task 2 done
346
+ Task 4 done
342
347
Task 7 done
343
348
Task 1 done
344
- Task 3 done
345
- Task 6 done
346
349
Task 9 done
347
- Task 4 done
348
- Task 8 done
349
350
</ pre > </ code > </ p >
350
351
< p > In the synchronous case all the tasks are run sequentially,
351
352
which results in the main programming < em > blocking</ em > (
@@ -451,8 +452,8 @@ <h2 id="determinism">Determinism</h2>
451
452
non-determinism can creep into your program when you beging to
452
453
interact with outside services such as sockets and files. Thus
453
454
even 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 >
456
457
< p > The perennial problem involved with concurrency is known as a
457
458
< em > race condition</ em > . Simply put is when two concurrent threads
458
459
/ processes depend on some shared resource but also attempt to
@@ -621,6 +622,7 @@ <h2 id="timeouts">Timeouts</h2>
621
622
Greenlet.</ p >
622
623
< pre >
623
624
< code class ="python ">
625
+ import gevent
624
626
from gevent import Timeout
625
627
626
628
seconds = 10
@@ -995,7 +997,7 @@ <h2 id="gevent-zeromq">Gevent ZeroMQ</h2>
995
997
996
998
def server():
997
999
server_socket = context.socket(zmq.REQ)
998
- server_socket.bind("tcp://* :5000")
1000
+ server_socket.bind("tcp://127.0.0.1 :5000")
999
1001
1000
1002
for request in range(1,10):
1001
1003
server_socket.send("Hello")
@@ -1143,8 +1145,10 @@ <h2 id="wsgi-servers">WSGI Servers</h2>
1143
1145
1144
1146
< h2 id ="long-polling "> Long Polling</ h2 >
1145
1147
< pre >
1146
- < code class ="python "> from gevent.queue import Queue, Empty
1148
+ < code class ="python "> import gevent
1149
+ from gevent.queue import Queue, Empty
1147
1150
from gevent.pywsgi import WSGIServer
1151
+ import simplejson as json
1148
1152
1149
1153
data_source = Queue()
1150
1154
@@ -1335,10 +1339,6 @@ <h2 id="chat-server">Chat Server</h2>
1335
1339
http.serve_forever()
1336
1340
</ code >
1337
1341
</ 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 >
1342
1342
</ div >
1343
1343
</ body >
1344
1344
</ html >
0 commit comments