    async def publish(self):
        """Publish new events to the subscribers."""

        while True:
            event = await self.event_source.get()
            str_buffer = []

            if event == POISON_PILL:
                return

            if isinstance(event, str):
                str_buffer.append(event)

            elif event.type == EventTypes.BLOCK_VALID:
                str_buffer = map(json.dumps, eventify_block(event.data))

            for str_item in str_buffer:
                for _, websocket in self.subscribers.items():
                    await websocket.send_str(str_item)
Publish new events to the subscribers.
bigchaindb/web/websocket_server.py