Releases the file lock. Please note, that the lock is only completely released, if the lock counter is 0. Also note, that the lock file itself is not automatically deleted. :arg bool force: If true, the lock counter is ignored and the lock is r
(self, force = False)
| 298 | return _Acquire_ReturnProxy(lock = self) |
| 299 | |
| 300 | def release(self, force = False): |
| 301 | """ |
| 302 | Releases the file lock. |
| 303 | |
| 304 | Please note, that the lock is only completely released, if the lock |
| 305 | counter is 0. |
| 306 | |
| 307 | Also note, that the lock file itself is not automatically deleted. |
| 308 | |
| 309 | :arg bool force: |
| 310 | If true, the lock counter is ignored and the lock is released in |
| 311 | every case. |
| 312 | """ |
| 313 | with self._thread_lock: |
| 314 | |
| 315 | if self.is_locked: |
| 316 | self._lock_counter -= 1 |
| 317 | |
| 318 | if self._lock_counter == 0 or force: |
| 319 | lock_id = id(self) |
| 320 | lock_filename = self._lock_file |
| 321 | |
| 322 | logger().debug('Attempting to release lock %s on %s', lock_id, lock_filename) |
| 323 | self._release() |
| 324 | self._lock_counter = 0 |
| 325 | logger().debug('Lock %s released on %s', lock_id, lock_filename) |
| 326 | |
| 327 | return None |
| 328 | |
| 329 | def __enter__(self): |
| 330 | self.acquire() |