-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Invalid polars.lit causes panic, ungraceful termination or hang #14776
Comments
Ok I think this is related to #5606
This seems to be a trap. If end users are never supposed to see panics, then a catch-all and rethrow seems appropriate (perhaps for production builds or gated behind an env var). If users are expected to see panics, then having to catch a custom error seems inconvenient and error prone. Additionally, I've not confirmed, but it seems that generic error-catching assumptions of the multiprocessing library might extend to other libraries as well, and polars' (or any py03 library?) compatibility with them is degraded. I admit that this could be argued as expected behavior and not a bug, but I still contend that it is not ideal. I'll leave it open for comments. Many thanks for a great library. |
Simpler reproducer: import polars as pl
try:
raise pl.PolarsPanicError()
except Exception:
print("hello")
# pyo3_runtime.PanicException Indeed, I think this should be a proper Exception. The exception does subclass import polars as pl
try:
raise pl.PolarsPanicError()
except BaseException:
print("hello")
# hello The Python docs mention that exceptions should generally prefer to subclass
Perhaps this is a bug in PyO3. I'll check with them to see if there is anything we can do. We cannot really solve this in Polars I think. |
I reported this to PyO3: PyO3/pyo3#3918 I will close this for now as I don't think there's anything Polars can do about this. |
@stinodego Any response to my interpretation in PyO3/pyo3#3918 (comment) ? Edit: Thanks for the response and for looking into this! |
While the panic exception itself apparently does not subclass import polars as pl
df = pl.DataFrame({"x": [1, 2]}).with_columns(pl.lit([object()])) |
Checks
Reproducible example
The program terminates without printing 'error'
When run in a multiprocessing pool (childprocess), the program hangs.
Log output
Issue description
I'm not expecting polars to be able to accept or parse a nested list / ndarray as a literal. My input data is from a mat file and sometimes it's nested.
Expected behavior
I expect a panic to raise an error on invalid arguments or gracefully return to the calling function, which I believe would enable the multiprocessing pool to finish gracefully instead of hang.
Installed versions
The text was updated successfully, but these errors were encountered: