Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using contextvars, in order to support Trio #397

Merged
merged 23 commits into from
Apr 25, 2019
Merged

Conversation

itamarst
Copy link
Owner

@itamarst itamarst commented Apr 6, 2019

Fixes #290
Fixes #396

@itamarst
Copy link
Owner Author

itamarst commented Apr 8, 2019

This is broken. I need to switch to using just ContextVar.set/get, without managing our own stack; the latter is no longer necessary. And tests to demonstrate the problems I saw with Trio example.

@itamarst itamarst changed the title WIP: Switch to using contextvars, in order to support Trio Switch to using contextvars, in order to support Trio Apr 10, 2019
@itamarst
Copy link
Owner Author

Should in theory work now, modulo minor fixes.

@itamarst
Copy link
Owner Author

@jtrakk would appreciate some testing, if you have the time.

@jtrakk
Copy link

jtrakk commented Apr 19, 2019

I'm not sure what's supposed to happen if I continue an action in a subprocess (trio.Process) and an exception is raised inside that subprocess.

[...]
  File "/usr/lib/python3.7/contextlib.py", line 511, in __exit__
    raise exc_details[1]
  File "/usr/lib/python3.7/contextlib.py", line 496, in __exit__
    if cb(*exc_details):
  File "/usr/lib/python3.7/contextlib.py", line 377, in _exit_wrapper
    return cm_exit(cm, exc_type, exc, tb)
  File "/home/user/Documents/project/venv/lib/python3.7/site-packages/eliot/_action.py", line 414, in __exit__
    _ACTION_CONTEXT.reset(self._parent_token)
ValueError: <Token var=<ContextVar name='eliot.action' at 0x7f51b550c048> at 0x7f51b3f631f8> was created in a different Context

@itamarst
Copy link
Owner Author

Could you share a minimal reproducer? Thanks!

@jtrakk
Copy link

jtrakk commented Apr 25, 2019

The issue was due to my broken dual-purpose logging decorator implementation. I'll keep poking around and will update if I experience problems.

@itamarst itamarst merged commit 7510fb8 into master Apr 25, 2019
@itamarst itamarst deleted the 290.contextvars branch April 25, 2019 14:04
tomprince pushed a commit to tp-la/eliot that referenced this pull request Jul 14, 2021
Switch to using contextvars, in order to support Trio.
tomprince added a commit to tp-la/eliot that referenced this pull request Jul 14, 2021
When eliot switched to context vars in itamarst#397, this exception became unused.
Since it was never public, there is no reason to keep it around.
tomprince added a commit to tp-la/eliot that referenced this pull request Jul 14, 2021
When eliot switched to context vars in itamarst#397, this exception became unused.
Since it was never public, there is no reason to keep it around.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example of using Trio (and maybe asyncio while I'm at it?) Generic coroutine support
2 participants