5

I'm trying to find where the __enter__ and __exit__ methods of threading objects are documented for Python 2.7. The main documentation page on the topic has nothing of sort. Is this documented at all?

Is it, perhaps, so obvious what they should do, that I'm asking a nonsensical question? It's certainly not obvious to me. In my understanding, __enter__ should acquire a lock, and __exit__ should release it, but lock acquisition comes with optional parameters (blocking / non-blocking), so it's a bit ambiguous, at least to myself.

nobody
  • 19,814
  • 17
  • 56
  • 77
Phonon
  • 12,549
  • 13
  • 64
  • 114
  • 4
    Did you see [this](https://docs.python.org/2.7/library/threading.html#using-locks-conditions-and-semaphores-in-the-with-statement)? – BrenBarn May 24 '14 at 03:41
  • @BrenBarn No idea how I missed this..... long day, thanks. – Phonon May 24 '14 at 03:44

1 Answers1

0

As pointed out by BrenBarn in the first comment, the documentation does mention how to use locks with with statements here, which is implicit documentation for __enter__ and __exit__ (see `with` statment context managers).

Note: The documentation linked by BrenBarn was documentation for Python 2.7, the latest (at the moment of writing for Python 3.10) can be found here.

htellez
  • 1,269
  • 2
  • 13
  • 25