MCPcopy Create free account
hub / github.com/tox-dev/filelock / acquire_write

Method acquire_write

src/filelock/_async_read_write.py:122–138  ·  view source on GitHub ↗

Acquire an exclusive write lock. See :meth:`ReadWriteLock.acquire_write` for full semantics. :param timeout: maximum wait time in seconds; ``-1`` means block indefinitely :param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately when the lock is u

(self, timeout: float = -1, *, blocking: bool = True)

Source from the content-addressed store, hash-verified

120 return AsyncAcquireReadWriteReturnProxy(lock=self)
121
122 async def acquire_write(self, timeout: float = -1, *, blocking: bool = True) -> AsyncAcquireReadWriteReturnProxy:
123 """
124 Acquire an exclusive write lock.
125
126 See :meth:`ReadWriteLock.acquire_write` for full semantics.
127
128 :param timeout: maximum wait time in seconds; ``-1`` means block indefinitely
129 :param blocking: if ``False``, raise :class:`~filelock.Timeout` immediately when the lock is unavailable
130
131 :returns: a proxy that can be used as an async context manager to release the lock
132
133 :raises RuntimeError: if a read lock is already held, or a write lock is held by a different thread
134 :raises Timeout: if the lock cannot be acquired within *timeout* seconds
135
136 """
137 await self._run(self._lock.acquire_write, timeout, blocking=blocking)
138 return AsyncAcquireReadWriteReturnProxy(lock=self)
139
140 async def release(self, *, force: bool = False) -> None:
141 """

Callers 8

write_lockMethod · 0.95
test_reentrant_writeFunction · 0.95
test_upgrade_prohibitedFunction · 0.95
test_non_blocking_writeFunction · 0.95
test_release_forceFunction · 0.95
test_closeFunction · 0.95

Calls 2

_runMethod · 0.95

Tested by 7

test_reentrant_writeFunction · 0.76
test_upgrade_prohibitedFunction · 0.76
test_non_blocking_writeFunction · 0.76
test_release_forceFunction · 0.76
test_closeFunction · 0.76