def switch(self): """coro.switch() -> returnvalue switches to coroutine coro. If the bound function f finishes, the returnvalue is that of f, otherwise None is returned """ try: return greenlet.switch(self._frame) except TypeError, exp: # self._frame is the main coroutine return greenlet.switch(self._frame.something)