[pypy-dev] fiber support
Armin Rigo
armin.rigo at gmail.com
Wed Oct 18 06:59:17 EDT 2017
Hi David,
On 16 October 2017 at 21:18, David Callahan <dcallahan at fb.com> wrote:
> folly:fibers (https://github.com/facebook/folly/tree/master/folly/fibers )
> is a C++ package for lightweight, cooperatively scheduled threads. We have
> an application which extends this to CPython by adding the following
> save/restore code around task function invocation:
This will never work inside PyPy, even using cpyext, because cpyext's
notion of exceptions is different from the internal one inside PyPy.
Instead, you should look at the ``_continuation`` module or more
likely the ``greenlet`` module, which is built-in in PyPy (and
available as a CPython extension module, too, if you like). It should
give you a replacement, though of course you need to adapt the
callers.
If you really want to use folly:fibers or a specific package manipulating
the C stack, then I'm afraid it's quite hard. The ``greenlet``
module in PyPy is based on ``stacklet``, which is an internal part of
PyPy doing the same thing using the necessary bookkeeping for PyPy,
which is different than the one for CPython you included in your
e-mail. If you really want to look there, you'd need to replicate that
logic around folly:fibres (search for all "stacklet" file names in
several places in the PyPy source code).
A bientôt,
Armin.
More information about the pypy-dev
mailing list