Exemplo n.º 1
0
 def set_bound(self, key, marker, retries, type_=None):
     # api doesn't allow setting a bound with a blank marker
     if marker != " ":
         if type_ is None:
             type_ = self.type
         try:
             data = [obj_.to_dict(item, time=DEFAULT_TIME) for item in retries]
             client.set_worker_bound(self.dest_conn, type_, marker, DEFAULT_TIME, self.daemon_id, key, data=data)
             return RESULT_SUCCESS
         except Exception:
             log.warn(
                 'error setting worker bound for key "%s",' " may duplicate some work later. Traceback:",
                 key,
                 exc_info=True,
             )
             return RESULT_ERROR
Exemplo n.º 2
0
 def set_bound(self, key, marker, retries, type_=None):
     # api doesn't allow setting a bound with a blank marker
     if marker:
         if type_ is None:
             type_ = self.type
         try:
             data = [
                 obj_.to_dict(item, time=DEFAULT_TIME) for item in retries
             ]
             client.set_worker_bound(self.dest_conn,
                                     type_,
                                     marker,
                                     DEFAULT_TIME,
                                     self.daemon_id,
                                     key,
                                     data=data)
             return RESULT_SUCCESS
         except Exception:
             log.warn('error setting worker bound for key "%s",'
                      ' may duplicate some work later. Traceback:', key,
                      exc_info=True)
             return RESULT_ERROR
Exemplo n.º 3
0
 def test_extra_keys_are_set(self):
     result = obj.to_dict(Empty(), a=1, b=2)
     assert result['a'] == 1
     assert result['b'] == 2
Exemplo n.º 4
0
 def test_overrides_dont_mess_up_other_keys(self):
     fake = Empty(a=1, b=2)
     result = obj.to_dict(fake, b=3)
     assert result.get('a') == 1
Exemplo n.º 5
0
 def test_overrides_are_respected(self):
     fake = Empty(a=1, b=2)
     result = obj.to_dict(fake, b=3)
     assert result.get('b') == 3
Exemplo n.º 6
0
 def test_underscores_are_ignored(self):
     fake = Empty(a=1, _b=2)
     result = obj.to_dict(fake)
     assert result.get('_b') is None
     assert result.get('a') == 1