Make conditions immutable. Also fix issue #52.

#33 Merged
Repository
simpy-immutable-conditions
Branch
default
Repository
simpy
Branch
default
Author
  1. Ontje Lünsdorf
Reviewers
Description

@jancvanbruggen hit a problem with all_of conditions. Events of an all_of conditions were added sequentially and the condition was evaluated after each addition. If the first event had been processed, all_of would evaluate to True. This is fixed by adding all events at once and only checking them afterwards.

While fixing this, I discovered a separate bug. As an optimization, we allowed events to be added to an all_of condition using __iand__(). An untriggered event could be added to an already processed condition. The condition would remain processed, which is not correct.

I made conditions immutable by removing the optimization. The operators &= and |= will now always return a new condition, just like it happens in all other cases too. This results in a nice code cleanup, too :)

  • Issues #52: Incorrect AllOf Condition handling resolved

Comments (3)