In the documentation of the threading module it says:
All of the objects provided by this module that have
acquire()andrelease()methods can be used as context managers for awithstatement. Theacquire()method will be called when the block is entered, andrelease()will be called when the block is exited.
I was wondering if it is called in blocking or non-blocking mode?
From looking at the CPython source, it appears that it’s called with default arguments, which means in blocking mode.
The methods you want to look at in particular are
__enter__(), which is called at the beginning of thewithblock, and__exit__(), which is called at the end.