File tree Expand file tree Collapse file tree 4 files changed +12
-1
lines changed Expand file tree Collapse file tree 4 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Release 1.1 (dev)
44* add support for pypy
55* new :class:`concurrency.fields.ConditionalVersionField`
66* new decorator :class:`concurrency.api.concurrency_disable_increment`
7+ * :class:`concurrency.api.disable_concurrency` is now a noop if applied to a model not under concurrency management
8+
79
810Release 1.0.1
911-------------
Original file line number Diff line number Diff line change @@ -183,6 +183,10 @@ concurrency on any Model.
183183This features has been developed to be used in django commands
184184
185185
186+ .. versionchanged :: 1.1
187+
188+ Does not raise an exception if a model not under concurrency management is passed as argument.
189+
186190examples
187191~~~~~~~~
188192
Original file line number Diff line number Diff line change @@ -39,6 +39,6 @@ How to run the tests
3939
4040.. code-block:: bash
4141
42- $ pip tox
42+ $ pip install tox
4343 $ tox
4444
Original file line number Diff line number Diff line change @@ -114,8 +114,11 @@ class disable_concurrency(object):
114114 def __init__ (self , model = None ):
115115 self .model = model
116116 self .old_value = conf .ENABLED
117+ self .concurrency_managed = (model is None ) or hasattr (model , '_concurrencymeta' )
117118
118119 def __enter__ (self ):
120+ if not self .concurrency_managed :
121+ return
119122 if self .model is None :
120123 self .old_value , conf .ENABLED = conf .ENABLED , False
121124 elif isinstance (self .model , Model ):
@@ -125,6 +128,8 @@ def __enter__(self):
125128 self .old_value , self .model ._concurrencymeta .enabled = self .model ._concurrencymeta .enabled , False
126129
127130 def __exit__ (self , * args , ** kwds ):
131+ if not self .concurrency_managed :
132+ return
128133 if self .model is None :
129134 conf .ENABLED = self .old_value
130135 elif isinstance (self .model , Model ):
You can’t perform that action at this time.
0 commit comments