Exemplo n.º 1
0
            def action_callback(e):
                if c._has_completed():
                    return

                if e:
                    rules.abandon_action(self._handle, c._handle)
                    complete(e, None)
                else:
                    try:
                        rules.update_state(self._handle, json.dumps(c.s._d, ensure_ascii=False))
                        
                        new_result = rules.complete_and_start_action(self._handle, c._handle)
                        if new_result:
                            result_container['message'] = json.loads(new_result)
                        else:
                            complete(None, state)
                                    
                    except BaseException as error:
                        t, v, tb = sys.exc_info()
                        print('base exception type {0}, value {1}, traceback {2}'.format(t, str(v), traceback.format_tb(tb)))
                        rules.abandon_action(self._handle, c._handle)
                        complete(error, None)
                    except:
                        print('unknown exception type {0}, value {1}, traceback {2}'.format(t, str(v), traceback.format_tb(tb)))
                        rules.abandon_action(self._handle, c._handle)
                        complete('unknown error', None)

                    if c._is_deleted():
                        try:
                            self.delete_state(c.s['sid'])
                        except:
                           pass 
Exemplo n.º 2
0
 def update_state(self, state):
     state['$s'] = 1
     return rules.update_state(self._handle,
                               json.dumps(state, ensure_ascii=False))