Skip to content

Python 3.13 support #2213

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

Open
xrmx opened this issue Feb 6, 2025 · 6 comments · May be fixed by #2265
Open

Python 3.13 support #2213

xrmx opened this issue Feb 6, 2025 · 6 comments · May be fixed by #2265
Assignees

Comments

@xrmx
Copy link
Member

xrmx commented Feb 6, 2025

Python 3.13 raises an exception with how we buffer things to send to the apm server. When the gzip object is closed it raises an exception because the BytesIO used as its backing storage is already gone.

Filed an upstream issue python/cpython#129726 so waiting for some feedback here before reworking our code.

@Maksych
Copy link

Maksych commented Feb 11, 2025

How to produce this ignored exception:

import elasticapm

elasticapm.Client({})

Then got output:

No custom SERVICE_NAME was set -- using non-descript default 'unknown-python-service'
Could not register elasticapm.metrics.sets.cpu.CPUMetricSet metricset: psutil not found. Install it to get system and process metrics
Exception ignored in: <gzip on 0x10443e590>
Traceback (most recent call last):
  File "/Users/maksych/.local/share/uv/python/cpython-3.13.0-macos-aarch64-none/lib/python3.13/gzip.py", line 378, in close
    fileobj.write(self.compress.flush())
ValueError: I/O operation on closed file.

@josecsotomorales
Copy link

josecsotomorales commented Feb 12, 2025

Following up, is there any workaround on this one? I see a draft PR with 3.13 support though

@zffocussss
Copy link

when is it fixed?

@meako689
Copy link

meako689 commented Apr 2, 2025

to suppress the message from polluting the logs in your project, this can be done

import sys

def suppressor(unraisable):  # type: ignore
    if unraisable.exc_type is ValueError and "I/O operation on closed file" in str(unraisable.exc_value):
        pass
    else:
        sys.__unraisablehook__(unraisable)


sys.unraisablehook = suppressor

@xrmx
Copy link
Member Author

xrmx commented Apr 8, 2025

Yesterday I merged the PR fixing a couple of warnings in main, still in order to have other warnings fixed we are waiting for a Python 3.13 patch release including python/cpython#129726 . If anyone would like to give current main a try it would be much appreciated.

@josecsotomorales
Copy link

Thanks @xrmx !! Just saw the issue in CPython; that one was nasty! 🚀

@xrmx xrmx self-assigned this Apr 9, 2025
@xrmx xrmx linked a pull request Apr 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants