"Phillip J. Eby" <pje at telecommunity.com>: > If you could throw a special kind of exception (or even a regular > exception), and call traceback.resume() to pick up execution at the > point where it was thrown, whether thrown by a generator or a > regular function. Actually, it probably wouldn't be too hard to make exceptions resumable -- provided all the frames in between are Python. If the exception gets thrown through any C calls, though, resumption becomes impossible. Some other structure is needed to hold the state of a resumable C call. I agree that maintaining a stack of *ators automatically somehow would be desirable, but I haven't figured out yet exactly where and how that stack would be maintained. > What's really needed (IMO) is to add a way to communicate *into* a > co-operator, passing it a value to "accept" or a traceback to raise. > E.g.: > > input = suspend output There have been many suggestions in the past for 'yield' to be extended to allow values to be passed in as well as out. They all suffer from a problem of asymmetry. However you arrange it, you always end up having to discard the first value passed out or pass a dummy value in the first time, or something like that. I deliberately left communication out of the suspend to avoid those problems. If you want communication, you have to arrange it some other way. > Anyway, as I said, what would be *most* useful for async programming is a > way to resume a traceback, because then you wouldn't need for every > intervening frame to have special suspension capability. Certainly, but that way, ultimately, lies Stackless... Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4