I/O operation on closed file exception with --log
#219

Comments

When using the --log option, a "ValueError: I/O operation on closed file exception" is raised when an error occurs.

$ pip install abcxyz --log=test.log
Downloading/unpacking abcxyz
Could not fetch URL http://pypi.python.org/simple/abcxyz: HTTP Error 404: Not Found (abcxyz does not have any releases)
Will skip URL http://pypi.python.org/simple/abcxyz when looking for download links for abcxyz
Could not find any downloads that satisfy the requirement abcxyz
No distributions at all found for abcxyz
Storing complete log in ./pip-log.txt
Traceback (most recent call last):
File "/usr/bin/pip", line 3, in <module>
pip.main()
File "/usr/lib/python2.6/dist-packages/pip.py", line 893, in main
return command.main(initial_args, args[1:], options)
File "/usr/lib/python2.6/dist-packages/pip.py", line 266, in main
logger.fatal('Storing complete log in %s' % log_fn)
File "/usr/lib/python2.6/dist-packages/pip.py", line 3353, in fatal
self.log(self.FATAL, msg, *args, **kw)
File "/usr/lib/python2.6/dist-packages/pip.py", line 3378, in log
consumer.write(rendered+'\n')
ValueError: I/O operation on closed file

This comment has been minimized.

Still occurs on develop, we explicitly close log_fd before the exit block, removing the log statement there prevents the traceback, which I may propose for now and then look at improving logging in general later (eg there are no timestamps, etc).

Still occurs on develop, we explicitly close log_fd before the exit block, removing the log statement there prevents the traceback, which I may propose for now and then look at improving logging in general later (eg there are no timestamps, etc).

This comment has been minimized.

Was having the same issue today while pip installing on a RHEL machine where the user didn't have a writable home directory. Even while passing --log and --log-file arguments, it still tried to write out to the ~/.pip/log file.

Note that this failure only occurred while installing requirements which compiled c-extensions. The --log argument did capture the regular pip log.

Was having the same issue today while pip installing on a RHEL machine where the user didn't have a writable home directory. Even while passing --log and --log-file arguments, it still tried to write out to the ~/.pip/log file.

Note that this failure only occurred while installing requirements which compiled c-extensions. The --log argument did capture the regular pip log.

This comment has been minimized.

I can confirm that this is still happening with pip 1.4.1. We see it frequently while testing pip over TUF.

Without logging:

$ pip install RandomNonExtantPackage
Downloading/unpacking RandomNonExtantPackage
Could not find any downloads that satisfy the requirement RandomNonExtantPackage
Cleaning up...
No distributions at all found for RandomNonExtantPackage
Storing complete log in /home/trishank/.pip/pip.log

I can confirm that this is still happening with pip 1.4.1. We see it frequently while testing pip over TUF.

Without logging:

$ pip install RandomNonExtantPackage
Downloading/unpacking RandomNonExtantPackage
Could not find any downloads that satisfy the requirement RandomNonExtantPackage
Cleaning up...
No distributions at all found for RandomNonExtantPackage
Storing complete log in /home/trishank/.pip/pip.log