diff options
| author | Michael Merickel <michael@merickel.org> | 2014-11-21 15:57:26 -0600 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2014-12-26 22:49:19 -0600 |
| commit | a52326b00b843b94b569d35a8d91a2a4c78b56a0 (patch) | |
| tree | 6ffef0b8d1fe06cd2bb6fe57d0cea5b9360c0808 | |
| parent | 5d2302a2b8d968245a123e54a8f01cd62c97cf69 (diff) | |
| download | pyramid-a52326b00b843b94b569d35a8d91a2a4c78b56a0.tar.gz pyramid-a52326b00b843b94b569d35a8d91a2a4c78b56a0.tar.bz2 pyramid-a52326b00b843b94b569d35a8d91a2a4c78b56a0.zip | |
refactor loop to combine conflict resolution paths into one
| -rw-r--r-- | pyramid/config/__init__.py | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py index e907cbb14..740c9c47d 100644 --- a/pyramid/config/__init__.py +++ b/pyramid/config/__init__.py @@ -1080,9 +1080,9 @@ class ActionState(object): """ try: - all_actions = self.actions - self.actions = [] + all_actions = [] executed_actions = [] + pending_actions = iter([]) # resolve the new action list against what we have already # executed -- if a new action appears intertwined in the list @@ -1095,19 +1095,32 @@ class ActionState(object): # common case is that we are executing every action yield a elif b is not None and a != b: - raise RuntimeError('Re-entrant failure - attempted ' - 'to resolve actions in a different ' - 'order from the active execution ' - 'path.') + raise ConfigurationError( + 'Re-entrant failure - attempted to resolve ' + 'actions in a different order from the active ' + 'execution path.') else: # resolved action is in the same location as before, # so we are in good shape, but the action is already # executed so we skip it assert b is not None and a == b - pending_actions = resume(resolveConflicts(all_actions)) - action = next(pending_actions, None) - while action is not None: + while True: + # We clear the actions list prior to execution so if there + # are some new actions then we add them to the mix and resolve + # conflicts again. This orders the new actions as well as + # ensures that the previously executed actions have no new + # conflicts. + if self.actions: + all_actions.extend(self.actions) + self.actions = [] + pending_actions = resume(resolveConflicts(all_actions)) + + action = next(pending_actions, None) + if action is None: + # we are done! + break + callable = action['callable'] args = action['args'] kw = action['kw'] @@ -1128,7 +1141,7 @@ class ActionState(object): ConfigurationExecutionError(t, v, info), tb) finally: - del t, v, tb + del t, v, tb if introspector is not None: for introspectable in introspectables: @@ -1136,17 +1149,6 @@ class ActionState(object): executed_actions.append(action) - # We cleared the actions list prior to execution so if there - # are some new actions then we add them to the mix and resolve - # conflicts again. This orders the new actions as well as - # ensures that the previously executed actions have no new - # conflicts. - if self.actions: - all_actions.extend(self.actions) - self.actions = [] - pending_actions = resume(resolveConflicts(all_actions)) - action = next(pending_actions, None) - finally: if clear: del self.actions[:] |
