Apparently working sink handler

This commit is contained in:
Pedro Ferreira 2017-07-30 10:52:04 +02:00
parent e2e893018b
commit 02f50239fc
2 changed files with 7 additions and 2 deletions

View File

@ -22,8 +22,8 @@ class MuxRPCSourceHandler(object):
class MuxRPCSinkHandlerMixin(object): class MuxRPCSinkHandlerMixin(object):
def send(self, msg, msg_type=PSMessageType.JSON): def send(self, msg, msg_type=PSMessageType.JSON, end=False):
self.connection.send(msg, stream=True, msg_type=msg_type, req=self.req) self.connection.send(msg, stream=True, msg_type=msg_type, req=self.req, end_err=end)
class MuxRPCDuplexHandler(MuxRPCSinkHandlerMixin, MuxRPCSourceHandler): class MuxRPCDuplexHandler(MuxRPCSinkHandlerMixin, MuxRPCSourceHandler):

View File

@ -47,7 +47,12 @@ async def main():
handler.send(struct.pack('l', int(time.time() * 1000)), msg_type=PSMessageType.BUFFER) handler.send(struct.pack('l', int(time.time() * 1000)), msg_type=PSMessageType.BUFFER)
async for msg in handler: async for msg in handler:
print('> RESPONSE:', msg) print('> RESPONSE:', msg)
handler.send(True, end=True)
break
handler = api.call('blobs.add', [], 'sink')
handler.send(b'dead0beef', msg_type=PSMessageType.BUFFER)
handler.send(True, end=True)
# create console handler and set level to debug # create console handler and set level to debug
ch = logging.StreamHandler() ch = logging.StreamHandler()