예제 #1
0
 def _serialise(self, message: Message,
                serial) -> (bytes, Optional[array.array]):
     if serial is None:
         serial = next(self.outgoing_serial)
     fds = array.array('i') if self.enable_fds else None
     data = message.serialise(serial=serial, fds=fds)
     return data, fds
예제 #2
0
 def send(self, message: Message, serial=None):
     """Serialise and send a :class:`~.Message` object"""
     if serial is None:
         serial = next(self.outgoing_serial)
     data = message.serialise(serial=serial)
     with self.send_lock:
         self.sock.sendall(data)
예제 #3
0
 async def send(self, message: Message, *, serial=None):
     """Serialise and send a :class:`~.Message` object"""
     async with self.send_lock:
         if serial is None:
             serial = next(self.outgoing_serial)
         self.writer.write(message.serialise(serial))
         await self.writer.drain()