Skip to content

Ensure that every new Trio task returns 'trio' from sniffio.current_async_library() - #2574

Closed
oremanj wants to merge 4 commits into
python-trio:masterfrom
oremanj:sniffio-fix
Closed

oremanj wants to merge 4 commits into
python-trio:masterfrom
oremanj:sniffio-fix

Conversation

@oremanj

@oremanj oremanj commented Feb 21, 2023

Copy link
Copy Markdown
Member

Previously the context in which start_soon() was called would be inherited, which is a problem when doing cross-library calls.

@gschaffner

gschaffner commented Feb 22, 2023 •

Copy link
Copy Markdown
Member

this is a duplicate of #2462!

this PR has a couple minor differences from #2462, however:

Comment thread newsfragments/2574.bugfix.rst Outdated
@@ -1 +1 @@
Fix :func:`sniffio.current_async_library` when Trio tasks are spawned from a non-Trio context (such as when using trio-asyncio). Previously, a regular Trio task would inherit the non-Trio library name, and spawning a system task would cause the non-Trio caller to start thinking it was Trio.
Fix ``sniffio.current_async_library()`` when Trio tasks are spawned from a non-Trio context (such as when using trio-asyncio). Previously, a regular Trio task would inherit the non-Trio library name, and spawning a system task would cause the non-Trio caller to start thinking it was Trio.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe you should be able to revert de460aa if you apply the patch

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 7200d913..17ed2320 100755
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -91,6 +91,7 @@ intersphinx_mapping = {
     "python": ("https://docs.python.org/3", None),
     "outcome": ("https://outcome.readthedocs.io/en/latest/", None),
     "pyopenssl": ("https://www.pyopenssl.org/en/stable/", None),
+    "sniffio": ("https://sniffio.readthedocs.io/en/latest/", None),
 }

 autodoc_member_order = "bysource"

@codecov

codecov Bot commented Mar 5, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #2574 (b4a65f0) into master (4bd5ba9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2574   +/-   ##
=======================================
  Coverage   92.45%   92.45%           
=======================================
  Files         118      118           
  Lines       16345    16350    +5     
  Branches     3155     3156    +1     
=======================================
+ Hits        15112    15117    +5     
  Misses       1104     1104           
  Partials      129      129           
Impacted Files Coverage Δ
trio/_threads.py 100.00% <ø> (ø)
trio/_core/_run.py 98.49% <100.00%> (-0.01%) ⬇️
trio/_core/tests/test_run.py 100.00% <100.00%> (ø)

@richardsheridan

Copy link
Copy Markdown
Contributor

#2462 contains these changes!

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.

3 participants