File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
source_py3/python_toolbox/context_management Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,28 @@ def as_reentrant(context_manager):
109109 Note: The first value returned by `__enter__` will be returned by all the
110110 subsequent no-op `__enter__` calls.
111111
112- blocktodo: add to docs about different ways of calling, ensure tests
112+ This can be used when calling an existing context manager:
113+
114+ with as_reentrant(some_context_manager):
115+ # Now we're reentrant!
116+
117+ Or it can be used when defining a context manager to make it reentrant:
118+
119+ @as_reentrant
120+ class MyContextManager(ContextManager):
121+ def __enter__(self):
122+ # ...
123+ def __exit__(self, exc_type, exc_value, exc_traceback):
124+ # ...
125+
126+ And also like this...
127+
128+
129+ @as_reentrant
130+ @ContextManagerType
131+ def Meow():
132+ yield # ...
133+
113134 '''
114135 return _ReentrantContextManager ._wrap_context_manager_or_class (
115136 context_manager ,
You can’t perform that action at this time.
0 commit comments