Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ clcache changelog
which can be used to make clcache generate profiling information. The
generated data can be processed into a final report using a new
`showprofilereport.py` script.
* Improvement: Timeout errors when accessing the cache now generate friendlier
error messages mentioning the possibility to work around the issue using the
`CLCACHE_OBJECT_CACHE_TIMEOUT_MS` environment variable.

## clcache 3.2.0 (2016-07-28)

Expand Down
13 changes: 10 additions & 3 deletions clcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class CacheLock(object):
can be used in 'with' statements. """
INFINITE = 0xFFFFFFFF
WAIT_ABANDONED_CODE = 0x00000080
WAIT_TIMEOUT_CODE = 0x00000102

def __init__(self, mutexName, timeoutMs):
mutexName = 'Local\\' + mutexName
Expand All @@ -247,9 +248,15 @@ def acquire(self):
result = windll.kernel32.WaitForSingleObject(
self._mutex, wintypes.INT(self._timeoutMs))
if result not in [0, self.WAIT_ABANDONED_CODE]:
errorString = 'Error! WaitForSingleObject returns {result}, last error {error}'.format(
result=result,
error=windll.kernel32.GetLastError())
if result == self.WAIT_TIMEOUT_CODE:
errorString = \
'Failed to acquire cache lock after {}ms; ' \
'try setting CLCACHE_OBJECT_CACHE_TIMEOUT_MS environment variable to a larger value.'.format(
self._timeoutMs)
else:
errorString = 'Error! WaitForSingleObject returns {result}, last error {error}'.format(
result=result,
error=windll.kernel32.GetLastError())
raise CacheLockException(errorString)
self._acquired = True

Expand Down