Skip to content
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

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

Closed
vbabiy opened this issue Mar 15, 2011 · 6 comments
Closed

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

vbabiy opened this issue Mar 15, 2011 · 6 comments
Assignees
Labels
auto-locked Outdated issues that have been locked by automation C: logging Information Logging type: bug A confirmed bug or unintended behavior

Comments

@vbabiy
Copy link
Contributor

vbabiy commented Mar 15, 2011

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

@pnasrat
Copy link
Contributor

pnasrat commented May 1, 2011

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).

@pnasrat
Copy link
Contributor

pnasrat commented May 6, 2011

Possibly the fix proposed in Issue #114 would fix this.

@thurloat
Copy link

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.

@ghost ghost assigned hltbra Apr 19, 2013
@andresriancho
Copy link

I'm also seeing this error in my installs and it's really annoying!

@hltbra did you send a pull request to the pip project for this?

@trishankkarthik
Copy link
Member

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

With logging:

$ pip install RandomNonExtantPackage --log iamalog.txt
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
Traceback (most recent call last):
  File "/home/trishank/stress-test.updateframework.com/test/bin/pip", line 9, in <module>
    load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/__init__.py", line 148, in main
    return command.main(args[1:], options)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/basecommand.py", line 176, in main
    logger.fatal('Storing complete log in %s' % log_fn)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/log.py", line 48, in fatal
    self.log(self.FATAL, msg, *args, **kw)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/log.py", line 75, in log
    backwardcompat.fwrite(consumer, rendered)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/backwardcompat/__init__.py", line 90, in fwrite
    f.write(s)
ValueError: I/O operation on closed file

@qwcode
Copy link
Contributor

qwcode commented Sep 20, 2013

fixed in PR #1205

@qwcode qwcode closed this as completed Sep 20, 2013
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: logging Information Logging type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

7 participants