Use real loggers and not write to stdout
Hi! I am working with newrelic-admin to run some programs and one of them calls a script in a different venv making this to fail.
https://github.com/newrelic/newrelic-python-agent/blob/f99da493986f24a588af50e197bbe62f5ad6332a/newrelic/bootstrap/sitecustomize.py#L168
My problem is this is the expected behavior but this warning is being appended to the output of my script due to it being written to stdout instead of handling this with real loggers.
Thanks in advance for reading this!
Hello,
So to be clear you're intentionally calling python scripts in a different virtual environment, and not intending for them to be wrapped by newrelic-admin, correct?
In that case your PYTHONPATH environment variable has been edited by our bootstrap scripts, you should be able to fix the issue and remove all of newrelic from your other scripts by adjusting the PYTHONPATH manually. You might even be able to get away with setting it to an empty string. If you remove us from that our sitecustomize shouldn't be picked up anymore and you'll see the error go away. Can you try that?
The main problem with using loggers and things is that sitecustomize is super early into the bootstrap process and we try to avoid importing anything if possible, to give anything that might be doing things like monkeypatching a chance to set import hooks. We could possibly add a separate environment variable to direct these messages to a log file instead of stdout but if the above is possible we'd like to avoid adding that.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.