[Python-ideas] PEP 550 v2
Nick Coghlan
ncoghlan at gmail.com
Thu Aug 17 05:46:58 EDT 2017
On 17 August 2017 at 02:55, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> 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:
>
> class Task:
>
> def __init__(self, coro):
> ...
> self.local_context = sys.new_local_context()
> self.exec_context = sys.get_execution_context()
>
> def step():
>
> sys.run_with_contexts(self.exec_context, self.local_context,
> self.coro.send)
I don't think that's entirely true, since you can nest the calls even
without a combined API:
sys.run_with_execution_context(self.exec_context,
sys.run_with_local_context, self.local_context, self.coro.send)
Offering a combined API may still make sense for usability and
efficiency reasons, but it isn't strictly necessary.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list