<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def publish(self):
 """Publish new events to the subscribers."""


        while True:
            event = yield from 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():
                    yield from websocket.send_str(str_item)