-
Notifications
You must be signed in to change notification settings - Fork 3k
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
logging.py broken when running in threading with indent_log context mgr #3889
Comments
I to have the same error when installing from inside a thread |
I'm not quite sure how the I'd recommend changing your plugin manager to call pip via |
I have a workaround. It sets the attribute indentation in pip.utils.logging._log_state setattr(pip.func_globals['utils'].logging._log_state, 'indentation', 0) I know it's not ideal. but stopped the indentation problem. now i have an issue with it not getting the ssl. if you could let me know if you encounter the same that would be helpful. |
@pfmoore I don't own the project facing this issue, yet I didn't expect pip did not support programming API given the enormous examples using of pip.main() you can find out there. It's a very convenient way to invoke pip from within a program, but I understand the concern for not being thread safe, good to know! This error comes from the utils/logging.py module which seemed to have a context manager ( If |
@rawouter I'd suggest you report to the upstream project that their usage of pip is unsupported. Other than that, all I can suggest is that if you were to raise a PR to fix this issue, one of the pip devs may be willing to merge it (I won't, because I don't want to get sucked into the rabbit hole of threading issues). But running pip on a thread remains a bad idea. What if 2 threads run |
Thanks @pfmoore ! Reported upstream. I don't think it's wise to raise a PR in this case indeed, at least this issue will prevent some usage of pip in threading and the trace should link to this issue. Is it worth to document this further, or to review the logging.py code to remove the usage threading there? |
I made #4654 to address this. |
Summary (for clarity) pip does not support use in-process via its internal API, and in particular the pip code makes no guarantees that it can be used safely in the presence of threads. |
Description:
Pip logging in threading is broken when installing requirements with ident_log().
The _log_state object in the thread does not have the parent indentation attribute in:
https://github.com/pypa/pip/blob/master/pip/utils/logging.py#L34 (and L38)
See repro below. For the backgroung, this is a traceback I get when installing plugins in errbotio/errbot from within a thread:
Triggered from https://github.com/errbotio/errbot/blob/master/errbot/plugin_manager.py#L58
What I've run:
The text was updated successfully, but these errors were encountered: