def react(self, event): """Execute the action of this reactor. Note: the condition of this reactor is out of the scope of this method (please see method :obj:``react_conditionally()``) Args: reaction (function): the action to be executed condition (function, optional): the boolean condition to be satisfied """ self.reaction_function(event) self.reactions_count += 1 self.last_reaction_timestamp = ts.utc_now() self.id_last_event_reacted = event.id
def __setattr__(self, key, value): event = Event(DataOperationEventType, payload={ 'datum': { 'class': 'Observed', 'property': 'field' }, 'operation': 'modify', 'timestamp': stringify(utc_now()), 'meta': { 'old_value': self.field, 'new_value': value } }) super().__setattr__(key, value) brq.publish(event)
def touch(self): """Sets the current time as timestamp of this event""" self.timestamp = ts.utc_now()
def test_utc_now(): utc_ts = timestamp.utc_now() assert utc_ts.tzinfo is not None