Skip to content

Commit

Permalink
Add greenlet support
Browse files Browse the repository at this point in the history
  • Loading branch information
rday committed Nov 8, 2016
1 parent 09eae5a commit 1ed65d5
Show file tree
Hide file tree
Showing 9 changed files with 2,155 additions and 3 deletions.
5 changes: 3 additions & 2 deletions python3/Makefile
Expand Up @@ -42,17 +42,18 @@ build/hostpython: | dl/$(TARBALL)
mv build/python build/hostpython mv build/python build/hostpython


build/Parser/hostpgen: build/hostpython build/Parser/hostpgen: build/hostpython
mv build/Parser/pgen build/Parser/hostpgen cp build/Parser/pgen build/Parser/hostpgen


build/Programs/host_freeze_importlib: build/Parser/hostpgen build/Programs/host_freeze_importlib: build/Parser/hostpgen
mv build/Programs/_freeze_importlib build/Programs/host_freeze_importlib cp build/Programs/_freeze_importlib build/Programs/host_freeze_importlib


build/configure: build/Programs/host_freeze_importlib build/configure: build/Programs/host_freeze_importlib
(cd build; make distclean) (cd build; make distclean)


build/stamp_patch: build/configure patches/* build/stamp_patch: build/configure patches/*
cp config.site build/ cp config.site build/
(cd build && ../../scripts/apply-patches.sh ./ ../patches/*) (cd build && ../../scripts/apply-patches.sh ./ ../patches/*)
cp -R files/* build/Modules/
touch $@ touch $@


build/Makefile: build/stamp_patch build/Makefile: build/stamp_patch
Expand Down
3 changes: 3 additions & 0 deletions python3/README.md
Expand Up @@ -21,6 +21,9 @@ but not everything. If you have an ImportError while trying to import a module
you feel should exist, please examine the `build/Modules/Setup` file to make you feel should exist, please examine the `build/Modules/Setup` file to make
sure it is compiled into Python. sure it is compiled into Python.


[Greenlets](https://greenlet.readthedocs.io/en/latest/) support is built into this
package. Greenlets are like coroutines. The example script includes greenlets so
you can see how they operate.


Instructions Instructions
============ ============
Expand Down
19 changes: 18 additions & 1 deletion python3/examples/main.py
Expand Up @@ -9,6 +9,8 @@
import json import json
import csv import csv


from greenlet import greenlet



def hello_world(): def hello_world():
print("\n" * 4) print("\n" * 4)
Expand All @@ -27,6 +29,21 @@ def hello_world():


print("\n" * 2) print("\n" * 2)



def test1():
print(12)
gr2.switch()
print(34)

def test2():
print(56)
gr1.switch()
print(78)


gr1 = greenlet(test1)
gr2 = greenlet(test2)

if __name__ == '__main__': if __name__ == '__main__':
hello_world() hello_world()

gr1.switch()

0 comments on commit 1ed65d5

Please sign in to comment.