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

[core] catch exception in async_callback #46488

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

hongchaodeng
Copy link
Member

Why are these changes needed?

async_callback doesn't catch the exception currently. cython will ignore the exception if any thrown.
This will break the test test_on_completed_callback_refcount on Python 3.12 because the traceback refcount is not decremented correctly. Since it is ignoring the exception before, simply logging it will fix the issue and still provide better user experience.

Related issue number

fix #46452

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

async_callback doesn't catch the exception currently.
cython will ignore the exception if any thrown.
This will break the test `test_on_completed_callback_refcount`
on Python 3.12 because the traceback refcount is not decremented correctly.
Since it is ignoring the exception before, simply logging it will fix the issue
and still provide better user experience.

Signed-off-by: hongchaodeng <hongchaodeng1@gmail.com>
@rynewang
Copy link
Contributor

rynewang commented Jul 8, 2024

why is the ref count not decremented since it's in finally block?

@hongchaodeng
Copy link
Member Author

hongchaodeng commented Jul 8, 2024

@rynewang
The traceback reference remains even after finally block due to some Python/Cython internal optimization. See the repro script in #46452
It's a regression due to upgrade. But catching it is what we should do anyway.

@hongchaodeng hongchaodeng added the go add ONLY when ready to merge, run all tests label Jul 9, 2024
@hongchaodeng
Copy link
Member Author

hongchaodeng commented Jul 9, 2024

why is the ref count not decremented since it's in finally block?

@rynewang The finally block is called. That's not the real issue. It's the traceback reference that remains.

python/ray/_raylet.pyx Outdated Show resolved Hide resolved
Signed-off-by: hongchaodeng <hongchaodeng1@gmail.com>
python/ray/_raylet.pyx Outdated Show resolved Hide resolved
Signed-off-by: hongchaodeng <hongchaodeng1@gmail.com>
@jjyao jjyao enabled auto-merge (squash) July 9, 2024 18:16
@jjyao jjyao merged commit 6b98284 into ray-project:master Jul 9, 2024
6 checks passed
hongchaodeng added a commit to hongchaodeng/ray that referenced this pull request Jul 9, 2024
Signed-off-by: hongchaodeng <hongchaodeng1@gmail.com>
can-anyscale pushed a commit that referenced this pull request Jul 9, 2024
backport.
fix
`python/ray/tests/test_asyncio.py::test_on_completed_callback_refcount[True]`

Signed-off-by: hongchaodeng <hongchaodeng1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: test_on_completed_callback_refcount failed on Python 3.12
3 participants