-
Notifications
You must be signed in to change notification settings - Fork 710
Bugfix/check future cancelled #2461
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
Merged
ocelotl
merged 21 commits into
open-telemetry:main
from
bourbonkk:bugfix/check-future-cancelled
May 7, 2024
Merged
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
70dc0e1
Calling the exception() method when future is in the cancelled state …
bourbonkk 17c776b
modify lint
bourbonkk 514e514
modify lint
bourbonkk 5d65a73
Update CHANGELOG.md
bourbonkk f2f7843
remove init()
allen-k1m a26f0af
add future cancelled test code
allen-k1m bab0b57
add future cancelled test code
allen-k1m f09597b
add future cancelled test code
allen-k1m 4e797c4
add future cancelled test code
allen-k1m 49fec30
add future cancelled test code
allen-k1m f94c7da
add future cancelled test code
allen-k1m 5c07243
lint
allen-k1m 0892214
lint
allen-k1m 9e10591
remove if condition
allen-k1m 1a7cd3d
modify test code
allen-k1m dfe74de
lint
allen-k1m b4a5f0c
lint
allen-k1m e1454b0
remove pytest
allen-k1m 92670ec
Merge branch 'main' into bugfix/check-future-cancelled
allen-k1m 7d5d277
Merge branch 'main' into bugfix/check-future-cancelled
allen-k1m a52e62b
Merge branch 'main' into bugfix/check-future-cancelled
ocelotl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...mentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_future_cancellation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
|
||
import pytest | ||
from opentelemetry.test.test_base import TestBase | ||
|
||
|
||
class TestTraceFuture(TestBase): | ||
|
||
@pytest.mark.asyncio | ||
aabmass marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def test_trace_future_cancelled(self): | ||
aabmass marked this conversation as resolved.
Show resolved
Hide resolved
|
||
loop = asyncio.new_event_loop() | ||
asyncio.set_event_loop(loop) | ||
|
||
future = asyncio.Future() | ||
future.cancel() | ||
|
||
def callback(f): | ||
state = "cancelled" if f.cancelled() else "done" | ||
self.assertEqual(state, "cancelled") | ||
|
||
future.add_done_callback(callback) | ||
|
||
try: | ||
loop.run_until_complete(future) | ||
except asyncio.CancelledError as e: | ||
self.assertEqual(isinstance(e, asyncio.CancelledError), True) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.