moneyapi / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Credential store locking fails on windows without pywin32 extensions installed #235

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Any attempt to put to or get from a credential multistore will fail when it 
tries to release the lock (when using the _PosixOpener).

storage = multistore_file.get_credential_storage(...)
storage.put(creds)

Will deterministically result in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "oauth2client\client.py", line 309, in put
    self.release_lock()
  File "oauth2client\multistore_file.py", line 138, in release_lock
    self._multistore._unlock()
  File "oauth2client\multistore_file.py", line 213, in _unlock
    self._file.unlock_and_close()
  File "oauth2client\locked_file.py", line 361, in unlock_and_close
    self._opener.unlock_and_close()
  File "oauth2client\locked_file.py", line 145, in unlock_and_close
    os.unlink(lock_filename)
WindowsError: [Error 32] The process cannot access the file because it is being 
used by another process: 'C:\\<file path>\\creds.lock'

It appears that this is the result of the following 2 lines in locked_file.py:
145:      os.unlink(lock_filename)
146:      os.close(self._lock_fd)

This will work on linux, but I don't believe the windows file system will allow 
you to unlink the directory entry while the file descriptor is in use.  
Reversing these two lines fixes the problem.

What version of the product are you using? On what operating system?
This is on windows 7 using
Version: 9c82c71824fc7b17035e8ff952734473043925b0

Original issue reported on code.google.com by markp...@google.com on 7 Feb 2013 at 7:01

GoogleCodeExporter commented 8 years ago
Committed in 
https://code.google.com/p/google-api-python-client/source/detail?r=5050cdc178f9d
ec6de99a5767feb59276c4716aa

Original comment by jcgregorio@google.com on 8 Feb 2013 at 3:34