mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Document objects that can be used with the `with
` statement.
This commit is contained in:
parent
bdfd693804
commit
168e99f6db
4 changed files with 94 additions and 2 deletions
|
@ -100,6 +100,19 @@ Return the status of the lock:\ \code{True} if it has been acquired by
|
|||
some thread, \code{False} if not.
|
||||
\end{methoddesc}
|
||||
|
||||
In addition to these methods, lock objects can also be used via the
|
||||
\keyword{with} statement, e.g.:
|
||||
|
||||
\begin{verbatim}
|
||||
from __future__ import with_statement
|
||||
import thread
|
||||
|
||||
a_lock = thread.allocate_lock()
|
||||
|
||||
with a_lock:
|
||||
print "a_lock is locked while this executes"
|
||||
\end{verbatim}
|
||||
|
||||
\strong{Caveats:}
|
||||
|
||||
\begin{itemize}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue