Skip to content

Commit

Permalink
Fix potential deadlock and delayed notification
Browse files Browse the repository at this point in the history
The hard limiter was checked before the value was set. That means, if
the user sets a valid outside the hard limit, he will not see an exception
(because we don't know yet if we are in hard limit) nor can he return to a valid
value later on (because we abort before we set anything).
  • Loading branch information
Matthias Vogelgesang committed Aug 16, 2013
1 parent 0769336 commit f96599e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions concert/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ def set(self, value, owner=None):
msg = "`{0}' can only receive values of unit {1} but got {2}"
raise UnitError(msg.format(self.name, self.unit, value))

if self.limiter and not self.limiter(value):
msg = "{0} for `{1}' is out of range"
raise LimitError(msg.format(value, self.name))

def log_access(what):
"""Log access."""
msg = "{0}: {1} {2}='{3}'"
Expand All @@ -242,6 +238,10 @@ def log_access(what):
else:
self._fset(value)

if self.limiter and not self.limiter(value):
msg = "{0} for `{1}' is out of range"
raise LimitError(msg.format(value, self.name))

log_access('set')
self.notify()

Expand Down

0 comments on commit f96599e

Please sign in to comment.