(reason)
| 27 | |
| 28 | |
| 29 | def acquire_cache_lock(reason): |
| 30 | global acquired_count |
| 31 | if config.FROZEN_CACHE: |
| 32 | # Raise an exception here rather than exit_with_error since in practice this |
| 33 | # should never happen |
| 34 | raise Exception('Attempt to lock the cache but FROZEN_CACHE is set') |
| 35 | |
| 36 | if not is_writable(cachedir): |
| 37 | utils.exit_with_error(f'cache directory "{cachedir}" is not writable while accessing cache for: {reason} (see https://emscripten.org/docs/tools_reference/emcc.html for info on setting the cache directory)') |
| 38 | |
| 39 | if acquired_count == 0: |
| 40 | logger.debug(f'PID {os.getpid()} acquiring multiprocess file lock to Emscripten cache at {cachedir}') |
| 41 | assert 'EM_CACHE_IS_LOCKED' not in os.environ, f'attempt to lock the cache while a parent process is holding the lock ({reason})' |
| 42 | try: |
| 43 | cachelock.acquire(10 * 60) |
| 44 | except filelock.Timeout: |
| 45 | logger.warning(f'Accessing the Emscripten cache at "{cachedir}" (for "{reason}") is taking a long time, another process should be writing to it. If there are none and you suspect this process has deadlocked, try deleting the lock file "{cachelock_name}" and try again. If this occurs deterministically, consider filing a bug.') |
| 46 | cachelock.acquire() |
| 47 | |
| 48 | os.environ['EM_CACHE_IS_LOCKED'] = '1' |
| 49 | logger.debug('done') |
| 50 | acquired_count += 1 |
| 51 | |
| 52 | |
| 53 | def release_cache_lock(): |
no test coverage detected