Пример #1
0
 def encode(buf, value, is_final=False):
     header = bytearray(SIZE_OF_FRAME_LENGTH_AND_FLAGS)
     LE_INT.pack_into(header, 0, SIZE_OF_FRAME_LENGTH_AND_FLAGS + len(value))
     if is_final:
         LE_UINT16.pack_into(header, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
     buf.extend(header)
     buf.extend(value)
Пример #2
0
    def test_invocation_not_timed_out_when_there_is_no_exception(self):
        buf = bytearray(22)
        LE_INT.pack_into(buf, 0, 22)
        request = OutboundMessage(buf, True)
        invocation_service = self.client._invocation_service
        invocation = Invocation(request)
        invocation_service.invoke(invocation)

        time.sleep(2)
        self.assertFalse(invocation.future.done())
        self.assertEqual(1, len(invocation_service._pending))
Пример #3
0
 def encode(buf, arr, is_final=False):
     n = len(arr)
     size = SIZE_OF_FRAME_LENGTH_AND_FLAGS + n * LONG_SIZE_IN_BYTES
     b = bytearray(size)
     LE_INT.pack_into(b, 0, size)
     if is_final:
         LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
     for i in range(n):
         FixSizedTypesCodec.encode_long(
             b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * LONG_SIZE_IN_BYTES,
             arr[i])
     buf.extend(b)
Пример #4
0
 def encode(buf, entries, is_final=False):
     n = len(entries)
     size = SIZE_OF_FRAME_LENGTH_AND_FLAGS + n * _UUID_LONG_ENTRY_SIZE_IN_BYTES
     b = bytearray(size)
     LE_INT.pack_into(b, 0, size)
     if is_final:
         LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
     for i in range(n):
         key, value = entries[i]
         o = SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * _UUID_LONG_ENTRY_SIZE_IN_BYTES
         FixSizedTypesCodec.encode_uuid(b, o, key)
         FixSizedTypesCodec.encode_long(b, o + UUID_SIZE_IN_BYTES, value)
     buf.extend(b)
Пример #5
0
 def encode_int(buf, offset, value):
     LE_INT.pack_into(buf, offset, value)