@@ -184,9 +184,9 @@ whole queue. In the async case the maximum runtime is roughly 2
184
184
seconds since none of the tasks block the execution of the
185
185
others.
186
186
187
- A more common use case, fetching data from a server
188
- asynchronously, the runtime of `` fetch() `` will differ between
189
- requests given the load on the remote server.
187
+ In a more common use case, asynchronously fetching data from a server,
188
+ the runtime of `` fetch() `` will differ between
189
+ requests, depending on the load on the remote server at the time of the request .
190
190
191
191
<pre ><code class =" python " >import gevent.monkey
192
192
gevent.monkey.patch_socket()
@@ -225,9 +225,9 @@ asynchronous()
225
225
## Determinism
226
226
227
227
As mentioned previously, greenlets are deterministic. Given the same
228
- configuration of greenlets and the same set of inputs and they always
229
- produce the same output. For example lets spread a task across a
230
- multiprocessing pool compared to a gevent pool.
228
+ configuration of greenlets and the same set of inputs, they always
229
+ produce the same output. For example, let's spread a task across a
230
+ multiprocessing pool and compare its results to the one of a gevent pool.
231
231
232
232
<pre >
233
233
<code class =" python " >
@@ -276,15 +276,14 @@ concurrency", they still can experience some of the same problems
276
276
that POSIX threads and processes experience.
277
277
278
278
The perennial problem involved with concurrency is known as a
279
- * race condition* . Simply put is when two concurrent threads
279
+ * race condition* . Simply put, a race condition occurs when two concurrent threads
280
280
/ processes depend on some shared resource but also attempt to
281
- modify this value. This results in resources whose values become
281
+ modify this value. This results in resources which values become
282
282
time-dependent on the execution order. This is a problem, and in
283
283
general one should very much try to avoid race conditions since
284
- they result program behavior which is globally
285
- non-deterministic.
284
+ they result in a globally non-deterministic program behavior.
286
285
287
- The best approach to this is to simply avoid all global state all
286
+ The best approach to this is to simply avoid all global state at all
288
287
times. Global state and import-time side effects will always come
289
288
back to bite you!
290
289
@@ -457,7 +456,7 @@ except Timeout:
457
456
</code >
458
457
</pre >
459
458
460
- Or with a context manager in a `` with `` statement.
459
+ They can also be used with a context manager, in a `` with `` statement.
461
460
462
461
<pre >
463
462
<code class =" python " >import gevent
@@ -566,7 +565,7 @@ of our gevent stack.
566
565
567
566
This lets us integrate libraries that would not normally work with
568
567
gevent without ever writing a single line of code. While monkey-patching
569
- is still evil, in this case it is a "usefull evil".
568
+ is still evil, in this case it is a "useful evil".
570
569
571
570
# Data Structures
572
571
@@ -684,7 +683,7 @@ either ``gevent.queue.Empty`` or
684
683
`` gevent.queue.Full `` in the operation is not possible.
685
684
686
685
In this example we have the boss running simultaneously to the
687
- workers and have a restriction on the Queue that it can contain no
686
+ workers and have a restriction on the Queue preventing it from containing
688
687
more than three elements. This restriction means that the `` put ``
689
688
operation will block until there is space on the queue.
690
689
Conversely the `` get `` operation will block if there are
@@ -759,10 +758,9 @@ group.join()
759
758
]]]
760
759
[[[ end]]]
761
760
762
- This is very usefull for managing groups of asynchronous tasks
763
- that.
761
+ This is very useful for managing groups of asynchronous tasks.
764
762
765
- As mentioned above Group also provides an API for dispatching
763
+ As mentioned above, `` Group `` also provides an API for dispatching
766
764
jobs to grouped greenlets and collecting their results in various
767
765
ways.
768
766
@@ -890,8 +888,8 @@ of a program.
890
888
891
889
## Thread Locals
892
890
893
- Gevnet also allows you to specify data which is local the
894
- greenlet context. Internally this is implemented as a global
891
+ Gevent also allows you to specify data which is local to the
892
+ greenlet context. Internally, this is implemented as a global
895
893
lookup which addresses a private namespace keyed by the
896
894
greenlet's `` getcurrent() `` value.
897
895
@@ -965,8 +963,8 @@ WSGIServer(('', 8000), application).serve_forever()
965
963
<code >
966
964
</pre >
967
965
968
- Flask's system is more a bit sophisticated than this example, but the
969
- idea of using thread locals as local session storage is nontheless the
966
+ Flask's system is a bit more sophisticated than this example, but the
967
+ idea of using thread locals as local session storage is nonetheless the
970
968
same.
971
969
972
970
## Subprocess
0 commit comments