Skip to content

It would be cool to get rid of assert in production code #371

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

Closed
xfenix opened this issue Dec 6, 2022 · 2 comments · Fixed by #379
Closed

It would be cool to get rid of assert in production code #371

xfenix opened this issue Dec 6, 2022 · 2 comments · Fixed by #379

Comments

@xfenix
Copy link

xfenix commented Dec 6, 2022

I suddenly discovered that arq production code (e.g., connection_pool) uses asserts.
This is unsafe because of the -O, -OO options in the python interpreter https://docs.python.org/3/using/cmdline.html#cmdoption-O, as well as the PYTHONOPTIMIZE environment variable.
I might suggest using instead of:

assert condition, message_body

something like this:

if not condition:
    raise AssertionError(message_body)
@JonasKs
Copy link
Collaborator

JonasKs commented Dec 7, 2022

Seems reasonable to me. I can fix / review tomorrow if @samuelcolvin accepts the request.

@iamlikeme
Copy link
Contributor

I had a look at some of the assert statements and it seems to me that it might be appropriate to raise RuntimeError instead of AssertionError.

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 a pull request may close this issue.

3 participants