def emit(<EOL>self,<EOL>tup,<EOL>tup_id=None,<EOL>stream=None,<EOL>anchors=None,<EOL>direct_task=None,<EOL>need_task_ids=False,<EOL>):
if not isinstance(tup, (list, tuple)):<EOL><INDENT>raise TypeError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(type(tup))<EOL>)<EOL><DEDENT>msg = {"<STR_LIT>": "<STR_LIT>", "<STR_LIT>": tup}<EOL>downstream_task_ids = None<EOL>if anchors is not None:<EOL><INDENT>msg["<STR_LIT>"] = anchors<EOL><DEDENT>if tup_id is not None:<EOL><INDENT>msg["<STR_LIT:id>"] = tup_id<EOL><DEDENT>if stream is not None:<EOL><INDENT>msg["<STR_LIT>"] = stream<EOL><DEDENT>if direct_task is not None:<EOL><INDENT>msg["<STR_LIT>"] = direct_task<EOL>if need_task_ids:<EOL><INDENT>downstream_task_ids = [direct_task]<EOL><DEDENT><DEDENT>if not need_task_ids:<EOL><INDENT>msg["<STR_LIT>"] = need_task_ids<EOL><DEDENT>if need_task_ids and direct_task is None:<EOL><INDENT>with self._reader_lock, self._writer_lock:<EOL><INDENT>self.send_message(msg)<EOL>downstream_task_ids = self.read_task_ids()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.send_message(msg)<EOL><DEDENT>return downstream_task_ids<EOL>
Emit a new Tuple to a stream.

        :param tup: the Tuple payload to send to Storm, should contain only
                    JSON-serializable data.
        :type tup: :class:`list` or :class:`pystorm.component.Tuple`
        :param tup_id: the ID for the Tuple. If omitted by a
                       :class:`pystorm.spout.Spout`, this emit will be
                       unreliable.
        :type tup_id: str
        :param stream: the ID of the stream to emit this Tuple to. Specify
                       ``None`` to emit to default stream.
        :type stream: str
        :param anchors: IDs the Tuples (or
                        :class:`pystorm.component.Tuple` instances)
                        which the emitted Tuples should be anchored to. This is
                        only passed by :class:`pystorm.bolt.Bolt`.
        :type anchors: list
        :param direct_task: the task to send the Tuple to.
        :type direct_task: int
        :param need_task_ids: indicate whether or not you'd like the task IDs
                              the Tuple was emitted (default: ``False``).
        :type need_task_ids: bool

        :returns: ``None``, unless ``need_task_ids=True``, in which case it will
                  be a ``list`` of task IDs that the Tuple was sent to if. Note
                  that when specifying direct_task, this will be equal to
                  ``[direct_task]``.