Release the currently held lock. In case the current thread holds no lock, a ValueError is thrown.
(self)
| 195 | self.__condition.release() |
| 196 | |
| 197 | def release(self): |
| 198 | """Release the currently held lock. |
| 199 | |
| 200 | In case the current thread holds no lock, a ValueError is thrown.""" |
| 201 | |
| 202 | me = currentThread() |
| 203 | self.__condition.acquire() |
| 204 | try: |
| 205 | if self.__writer is me: |
| 206 | # We are the writer, take one nesting depth away. |
| 207 | self.__writercount -= 1 |
| 208 | if not self.__writercount: |
| 209 | # No more write locks; take our writer position away and |
| 210 | # notify waiters of the new circumstances. |
| 211 | self.__writer = None |
| 212 | self.__condition.notifyAll() |
| 213 | elif me in self.__readers: |
| 214 | # We are a reader currently, take one nesting depth away. |
| 215 | self.__readers[me] -= 1 |
| 216 | if not self.__readers[me]: |
| 217 | # No more read locks, take our reader position away. |
| 218 | del self.__readers[me] |
| 219 | if not self.__readers: |
| 220 | # No more readers, notify waiters of the new |
| 221 | # circumstances. |
| 222 | self.__condition.notifyAll() |
| 223 | else: |
| 224 | raise ValueError("Trying to release unheld lock") |
| 225 | finally: |
| 226 | self.__condition.release() |
no outgoing calls
no test coverage detected