[pypy-dev] Advice needed debugging a Sys.exit error involving py.py and Stackless.py

Andrew Francis andrewfr_ice at yahoo.com
Sat Dec 12 01:02:39 CET 2009


Hello Folks:

I am trying to add a new function, stackless.select() to the Stackless.py module. This select() is loosely based on the select() in Newsqueak/Go. Once I get this select() to work, I would like to figure out some Python 
syntax to support it. One step deeper into PyPy :-)

For the most part, select() is pretty straightforward to implement. 
In two of my test cases, test4.py and test5.py, the select() function seems to work. Unfortunately, I get a sys.exit() error. 

I invoke the programme with 

python ../bin/py.py --withmod_-stackless testX.py

and I get
(test4.py)
THE RESULT FROM SELECT -> hello world
schedule(): returned from _schedule_switch
schedule(): about to _schedule_switch
schedule(): returned from _schedule_switch

File "../py.py", line 171, in <module>
    sys.exit(main_(sys.argv))
  File "../py.py", line 142, in main_
    verbose=interactiveconfig.verbose):
  File "/home/andrew/lab/pypy-dist/pypy/interpreter/main.py", line 103, in run_toplevel
    f()
....

 File "/home/andrew/lab/pypy-dist/pypy/interpreter/executioncontext.py", line 48, in leave
    self.framestack.pop()
  File "/home/andrew/lab/pypy-dist/pypy/interpreter/miscutils.py", line 34, in pop
    return self.items.pop()
IndexError: pop from empty list

and

(test5.py)
THE RESULT FROM SELECT -> hello world
schedule(): returned from _schedule_switch
schedule(): about to _schedule_switch
XXX error, nesting_level = 1
Traceback (most recent call last):
  File "../py.py", line 171, in <module>
    sys.exit(main_(sys.argv))
  File "../py.py", line 142, in main_
    verbose=interactiveconfig.verbose):
  File "/home/andrew/lab/pypy-dist/pypy/interpreter/main.py", line 103, in run_toplevel
    f()
...

 File "/home/andrew/lab/pypy-dist/pypy/interpreter/gateway.py", line 513, in funcrun_obj
    w_result = activation._run(space, scope_w)
  File "<codegen /home/andrew/lab/pypy-dist/pypy/tool/sourcetools.py:177>", line 3, in _run_UWS_AppCoroutine
  File "/home/andrew/lab/pypy-dist/pypy/module/_stackless/interp_coroutine.py", line 90, in w_switch
    self.switch()
  File "/home/andrew/lab/pypy-dist/pypy/rlib/rcoroutine.py", line 256, in switch
    incoming_frame = state.update(self).switch()
AttributeError: 'tuple' object has no attribute 'switch'


I wrote a third test, test6.py which blocks select() and then terminates because there is no tasklet on the other end. I do this on purpose. Test6.py works correctly making me suspect something is going wrong with the switching. Although I understand most of the Stackless.py module's code, I am still very green when it comes to PyPy and  the various coroutine packages.

I understand the PyPy team has not being developing Stackless.py for
a while. However I would greatly appreciate insights into figuring out
what is going  wrong. I would also appreciate insights into how to effectively debug PyPy. Eventually I would like to get into a position where I could support Stackless.py and continue its development. 

I have enclosed my copy of Stackless.py, the output, and some test
scripts. 

Cheers,
Andrew


      
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stackless.py
Type: text/x-python
Size: 21458 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20091211/da3c8e31/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test5.py
Type: text/x-python
Size: 855 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20091211/da3c8e31/attachment-0001.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test6.py
Type: text/x-python
Size: 686 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20091211/da3c8e31/attachment-0002.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: results4
Type: application/octet-stream
Size: 1938 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20091211/da3c8e31/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: results5
Type: application/octet-stream
Size: 7864 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20091211/da3c8e31/attachment-0001.obj>


More information about the Pypy-dev mailing list