Ejemplo n.º 1
0
 def push():
     try:
         pack_tid = None  # TODO
         for serial, oid in object_list:
             oid_set = object_dict.get(serial)
             if oid_set:
                 if type(oid_set) is list:
                     object_dict[serial] = oid_set = set(oid_set)
                 if oid in oid_set:
                     oid_set.remove(oid)
                     if not oid_set:
                         del object_dict[serial]
                     continue
             object = dm.getObject(oid, serial)
             if not object:
                 conn.send(
                     Errors.ReplicationError(
                         "partition %u dropped or truncated" %
                         partition), msg_id)
                 return
             conn.send(Packets.AddObject(oid, serial, *object[2:]),
                       msg_id)
             yield
         conn.send(
             Packets.AnswerFetchObjects(pack_tid, next_tid, next_oid,
                                        object_dict), msg_id)
         yield
     except (weakref.ReferenceError, ConnectionClosed):
         pass
Ejemplo n.º 2
0
 def push():
     try:
         pack_tid = None  # TODO
         for serial, oid in object_list:
             oid_set = object_dict.get(serial)
             if oid_set:
                 if type(oid_set) is tuple:
                     object_dict[serial] = oid_set = set(oid_set)
                 if oid in oid_set:
                     oid_set.remove(oid)
                     if not oid_set:
                         del object_dict[serial]
                     continue
             object = dm.fetchObject(oid, serial)
             if not object:
                 conn.send(
                     Errors.ReplicationError(
                         "partition %u dropped or truncated" %
                         partition), msg_id)
                 return
             if not object[2]:  # creation undone
                 object = object[0], 0, ZERO_HASH, '', object[4]
             # Same as in askFetchTransactions.
             conn.send(Packets.AddObject(oid, *object), msg_id)
             yield conn.buffering
         conn.send(
             Packets.AnswerFetchObjects(pack_tid, next_tid, next_oid,
                                        object_dict), msg_id)
         yield
     except (weakref.ReferenceError, ConnectionClosed):
         pass