Skip to content

Commit 5428710

Browse files
author
czheo
committed
do not recommend the using of green thread
1 parent 6e46bfb commit 5428710

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,23 @@ p(20)
6969

7070
### pipe with parallelism
7171

72-
By default, pipe works with green threads which is based on event loop.
72+
By default, pipe works with threads which is based on event loop.
7373

74-
You can have a function running in a seperate green thread with pipe. Just put it in a `[]` or more explicitly `g[]`. Threads and processes are also available.
74+
You can have a function running in a seperate thread with pipe. Just put it in a `[]` or more explicitly `t[]`. Threads and processes are also available.
7575

7676
``` python
77-
from syntax_sugar import (green_thread_syntax as g,
78-
thread_syntax as t,
77+
from syntax_sugar import (thread_syntax as t,
7978
process_syntax as p)
8079

81-
pipe(10) | [print] | END # print run in a green thread
82-
pipe(10) | g[print] | END # print run in a green thread
80+
pipe(10) | [print] | END # print run in a thread
8381
pipe(10) | t[print] | END # print run in a thread
8482
pipe(10) | p[print] | END # print run in a process
8583
```
8684

87-
What makes this syntax good is that you can specify how many green threads you want to spawn, by doing `[function] * n` where `n` is the number of green threads.
85+
What makes this syntax good is that you can specify how many threads you want to spawn, by doing `[function] * n` where `n` is the number of threads.
8886

8987
``` python
90-
pipe([1,2,3,4,5]) | [print] * 3 | END # print will run in a GreenThreadPool of size 3
88+
pipe([1,2,3,4,5]) | [print] * 3 | END # print will run in a ThreadPool of size 3
9189
```
9290

9391
Here is an example of requesting a list of urls in parallel
@@ -96,7 +94,7 @@ Here is an example of requesting a list of urls in parallel
9694
import requests
9795
(pipe(['google', 'twitter', 'yahoo', 'facebook', 'github'])
9896
| each(lambda name: 'http://' + name + '.com')
99-
| [requests.get] * 3 # !! `requests.get` runs in a GreenThreadPool of size 3
97+
| [requests.get] * 3 # !! `requests.get` runs in a ThreadPool of size 3
10098
| each(lambda resp: (resp.url, resp.headers.get('Server')))
10199
| list
102100
| END)

syntax_sugar/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
from .infix import *
55
from .stream import *
66
from .placeholder import *
7+
from eventlet import green

syntax_sugar/pipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def __or__(self, rhs):
124124
raise SyntaxError('Bad pipe multiprocessing syntax.')
125125
poolsize = len(rhs)
126126
new_action = rhs[0]
127-
self.action = compose(partial(multigreenthread, new_action, poolsize), self.action)
127+
self.action = compose(partial(multithread, new_action, poolsize), self.action)
128128
elif isinstance(rhs, ProcessSyntax):
129129
self.action = compose(partial(multiprocess, rhs.func, rhs.poolsize), self.action)
130130
elif isinstance(rhs, ThreadSyntax):

0 commit comments

Comments
 (0)