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

Bugfix/check future cancelled #2461

Merged
merged 21 commits into from
May 7, 2024

Conversation

bourbonkk
Copy link
Contributor

@bourbonkk bourbonkk commented Apr 26, 2024

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Using python auto instrumentation version 0.44b0 the real trace source is being deprecated.
Calling the exception() method when future is in the cancelled state is causing a CancelledError

Fixes #2460

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Execute Test Code
  • gitflow validation

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

…is causing a CancelledError

Calling the exception() method when future is in the cancelled state is causing a CancelledError. we should check the cancelled state first and call f.exception() only if it's not cancelled.
@bourbonkk bourbonkk requested a review from a team April 26, 2024 01:49
@xrmx
Copy link
Contributor

xrmx commented Apr 26, 2024

Could you please add a test?

Also #2392 looks a different solution of the same issue, like they choose to always pass an exception

@bourbonkk
Copy link
Contributor Author

bourbonkk commented Apr 26, 2024

Could you please add a test?

Also #2392 looks a different solution of the same issue, like they choose to always pass an exception

@xrmx
i've looked into the issue.
It's good code, but I have a slightly different opinion.
I don't report canceledError as an error in the span because there is a subject that did the cancel, and the coroutine follows the same strategy.

        # CancelledError is raised when a coroutine is cancelled
        # before it has a chance to run. We don't want to record
        # this as an error.

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Apologies for all the comments

@ocelotl ocelotl enabled auto-merge (squash) May 6, 2024 16:53
auto-merge was automatically disabled May 6, 2024 16:59

Pull Request is not mergeable

@ocelotl ocelotl merged commit bc804a3 into open-telemetry:main May 7, 2024
314 checks passed
shadchin pushed a commit to shadchin/opentelemetry-python-contrib that referenced this pull request May 29, 2024
* Calling the exception() method when future is in the cancelled state is causing a CancelledError

Calling the exception() method when future is in the cancelled state is causing a CancelledError. we should check the cancelled state first and call f.exception() only if it's not cancelled.

* modify lint

* modify lint

* Update CHANGELOG.md

* remove init()

* add future cancelled test code

* add future cancelled test code

* add future cancelled test code

* add future cancelled test code

* add future cancelled test code

* add future cancelled test code

* lint

* lint

* remove if condition

* modify test code

* lint

* lint

* remove pytest

---------

Co-authored-by: Diego Hurtado <ocelotl@users.noreply.github.com>
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.

Asyncio Instrumentation future cancelledError
4 participants