[pypy-issue] Issue #2017: greenlet.switch() raises MemoryError (pypy/pypy)

nxsofsys issues-reply at bitbucket.org
Sat Apr 4 02:08:49 CEST 2015


New issue 2017: greenlet.switch() raises MemoryError
https://bitbucket.org/pypy/pypy/issue/2017/greenletswitch-raises-memoryerror

nxsofsys:

Follwing script runned on [PyPy 2.5.1 with MSC v.1500 32 bit] (WIndows 7 x64)
```
#!python

import greenlet
from time import time

N = 1000 * 1000
count = 0
def func():
    global count
    count += 1
    main.switch()

main = greenlet.getcurrent()
try:
    start = time()
    for i in xrange(N):
        greenlet.greenlet(func).switch()
except:
    raise
finally:
    print '%s switches took %.3fs' % (count, time() - start)
```
prints following output:
```
2793 switches took 0.217s
Traceback (most recent call last):
  File "<builtin>/app_main.py", line 75, in run_toplevel
  File "bench.py", line 15, in <module>
    greenlet.greenlet(func).switch()
  File "C:\Env\pypy\lib_pypy\greenlet.py", line 53, in switch
    return self.__switch('switch', (args, kwds))
  File "C:\Env\pypy\lib_pypy\greenlet.py", line 69, in __switch
    _continulet.__init__(target, greenlet_func, *baseargs)
MemoryError
```
but on CPython with greenlet runs without errors.




More information about the pypy-issue mailing list