@@ -36,11 +36,6 @@ This module defines the following constants and functions:
3636 This is now a synonym of the built-in :exc: `RuntimeError `.
3737
3838
39- .. data :: LockType
40-
41- This is the type of lock objects.
42-
43-
4439.. function :: start_new_thread(function, args[, kwargs])
4540
4641 Start a new thread and return its identifier. The thread executes the
@@ -162,58 +157,59 @@ This module defines the following constants and functions:
162157 .. versionadded :: 3.2
163158
164159
165- Lock objects have the following methods:
166-
160+ .. class :: LockType
167161
168- .. method :: lock.acquire(blocking=True, timeout=-1)
162+ This is the type of lock objects.
169163
170- Without any optional argument, this method acquires the lock unconditionally, if
171- necessary waiting until it is released by another thread (only one thread at a
172- time can acquire a lock --- that's their reason for existence).
164+ Lock objects have the following methods:
173165
174- If the *blocking * argument is present, the action depends on its
175- value: if it is false, the lock is only acquired if it can be acquired
176- immediately without waiting, while if it is true, the lock is acquired
177- unconditionally as above.
166+ .. method :: acquire(blocking=True, timeout=-1)
178167
179- If the floating-point *timeout * argument is present and positive, it
180- specifies the maximum wait time in seconds before returning. A negative
181- *timeout * argument specifies an unbounded wait. You cannot specify
182- a *timeout * if *blocking * is false.
168+ Without any optional argument, this method acquires the lock unconditionally, if
169+ necessary waiting until it is released by another thread (only one thread at a
170+ time can acquire a lock --- that's their reason for existence).
183171
184- The return value is ``True `` if the lock is acquired successfully,
185- ``False `` if not.
172+ If the *blocking * argument is present, the action depends on its
173+ value: if it is false, the lock is only acquired if it can be acquired
174+ immediately without waiting, while if it is true, the lock is acquired
175+ unconditionally as above.
186176
187- .. versionchanged :: 3.2
188- The *timeout * parameter is new.
177+ If the floating-point *timeout * argument is present and positive, it
178+ specifies the maximum wait time in seconds before returning. A negative
179+ *timeout * argument specifies an unbounded wait. You cannot specify
180+ a *timeout * if *blocking * is false.
189181
190- .. versionchanged :: 3.2
191- Lock acquires can now be interrupted by signals on POSIX .
182+ The return value is `` True `` if the lock is acquired successfully,
183+ `` False `` if not .
192184
193- .. versionchanged :: 3.14
194- Lock acquires can now be interrupted by signals on Windows .
185+ .. versionchanged :: 3.2
186+ The * timeout * parameter is new .
195187
188+ .. versionchanged :: 3.2
189+ Lock acquires can now be interrupted by signals on POSIX.
196190
197- .. method :: lock.release()
191+ .. versionchanged :: 3.14
192+ Lock acquires can now be interrupted by signals on Windows.
198193
199- Releases the lock. The lock must have been acquired earlier, but not
200- necessarily by the same thread.
194+ .. method :: release()
201195
196+ Releases the lock. The lock must have been acquired earlier, but not
197+ necessarily by the same thread.
202198
203- .. method :: lock. locked()
199+ .. method :: locked()
204200
205- Return the status of the lock: ``True `` if it has been acquired by some thread,
206- ``False `` if not.
201+ Return the status of the lock: ``True `` if it has been acquired by some thread,
202+ ``False `` if not.
207203
208- In addition to these methods, lock objects can also be used via the
209- :keyword: `with ` statement, e.g.::
204+ In addition to these methods, lock objects can also be used via the
205+ :keyword: `with ` statement, e.g.::
210206
211- import _thread
207+ import _thread
212208
213- a_lock = _thread.allocate_lock()
209+ a_lock = _thread.allocate_lock()
214210
215- with a_lock:
216- print("a_lock is locked while this executes")
211+ with a_lock:
212+ print("a_lock is locked while this executes")
217213
218214**Caveats: **
219215
0 commit comments