Releases the file lock. Please note, that the lock is only completly 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 re
(self, force = False)
| 291 | return _Acquire_ReturnProxy(lock = self) |
| 292 | |
| 293 | def release(self, force = False): |
| 294 | """ |
| 295 | Releases the file lock. |
| 296 | |
| 297 | Please note, that the lock is only completly released, if the lock |
| 298 | counter is 0. |
| 299 | |
| 300 | Also note, that the lock file itself is not automatically deleted. |
| 301 | |
| 302 | :arg bool force: |
| 303 | If true, the lock counter is ignored and the lock is released in |
| 304 | every case. |
| 305 | """ |
| 306 | with self._thread_lock: |
| 307 | |
| 308 | if self.is_locked: |
| 309 | self._lock_counter -= 1 |
| 310 | |
| 311 | if self._lock_counter == 0 or force: |
| 312 | lock_id = id(self) |
| 313 | lock_filename = self._lock_file |
| 314 | |
| 315 | logger().debug('Attempting to release lock %s on %s', lock_id, lock_filename) |
| 316 | self._release() |
| 317 | self._lock_counter = 0 |
| 318 | logger().info('Lock %s released on %s', lock_id, lock_filename) |
| 319 | |
| 320 | return None |
| 321 | |
| 322 | def __enter__(self): |
| 323 | self.acquire() |