[Python-ideas] PEP 550 v2

Yury Selivanov yselivanov.ml at gmail.com
Wed Aug 16 22:15:20 EDT 2017


On Wed, Aug 16, 2017 at 12:55 PM, Yury Selivanov
[..]
> And immediately after I hit "send" I realized that this is a bit more
> complicated.
>
> In order for Tasks to remember the full execution context of where
> they were created, we need a new method that would allow to run with
> *both* exec and local contexts:

Never mind, the actual implementation would be as simple as:

     class Task:

        def __init__(self, coro):
            ...
            coro.cr_local_context = sys.new_local_context()
            self.exec_context = sys.get_execution_context()

        def step():

          sys.run_with_execution_context(self.exec_contex , self.coro.send)

No need for another "run_with_context" function.

Yury


More information about the Python-ideas mailing list