From 4a4c7e811bd0635e445cf30dd0559b594ce6d179 2012-07-21 03:14:31 From: Jason Grout Date: 2012-07-21 03:14:31 Subject: [PATCH] Add a metadata attribute to zeromq stdout/stderr stream messages --- diff --git a/IPython/zmq/iostream.py b/IPython/zmq/iostream.py index f20a660..cbe2e93 100644 --- a/IPython/zmq/iostream.py +++ b/IPython/zmq/iostream.py @@ -28,10 +28,15 @@ class OutStream(object): self.name = name self.parent_header = {} self._new_buffer() + self.metadata = {} def set_parent(self, parent): self.parent_header = extract_header(parent) + def set_metadata(self, metadata): + self.flush() + self.metadata = metadata + def close(self): self.pub_socket = None @@ -43,6 +48,8 @@ class OutStream(object): data = self._buffer.getvalue() if data: content = {u'name':self.name, u'data':data} + if self.metadata: + content['metadata'] = self.metadata msg = self.session.send(self.pub_socket, u'stream', content=content, parent=self.parent_header, ident=self.topic)