[pypy-issue] [issue719] stackless.coroutine cant switch to self

Da_Blitz pypy-dev-issue at codespeak.net
Thu May 12 09:21:08 CEST 2011

New submission from Da_Blitz <pypy at pocketnix.org>:

I have been playing around with the stackless module and went with the (what
appears to be undocumented) coroutines interface. as such i am unsure if this is
an actual bug. either way i can work around this (code that triggered it was a
coroutine scheduler where the coroutine switch was performed in the same
coroutine that is yielding to another. however if there is only one job in the
queue then it will grab a reference to self)

if in a coroutine you cannot switch to the same coroutine by calling "switch".
eg get a reference to the currently running coroutine via
stackless.getcoroutine() then call "switch" on the returned object

to reproduce:
def agent():
    t = stackless.getcurrent()

t = stackless.coroutine()
Produces the following traceback (on the interactive interpreter)

Traceback (most recent call last):
  File "<console>", line 1, in <module
  File "<console>", line 3, in agent
ValueError: cannot switch to an unbound Coroutine


effort: ???
messages: 2512
nosy: dablitz, pypy-issue
priority: bug
release: 1.5
status: unread
title: stackless.coroutine cant switch to self

PyPy development tracker <pypy-dev-issue at codespeak.net>

More information about the pypy-issue mailing list