예제 #1
0
파일: loop.py 프로젝트: pfreixes/qloop
    def _inherit_queue(self, coro):
        """Create a new task inheriting the partition
        assigned to the current task.

        If there is no current task, or the curren task
        does not have any queue will be assinged to the
        root one.

        Return a task object
        """
        task = Task(coro, loop=self)
        task.partition = _find_partition(self)
        if task._source_traceback:
            del task._source_traceback[-1]

        self._partitions[task.partition].add_task(task)
        task.add_done_callback(self._partitions[task.partition].remove_task,
                               task)
        return task
예제 #2
0
파일: loop.py 프로젝트: pfreixes/qloop
    def spawn(self, coro, partition=None):
        """Place and run a coro to a specific and isolated partition,
        if partition is not given a new one will be created.

        Return a task object bound to the coro.
        """
        task = Task(coro, loop=self)
        partition = partition if partition else task
        task.partition = partition

        if task._source_traceback:
            del task._source_traceback[-1]

        try:
            self._partitions[partition].tasks.add(task)
        except KeyError:
            self._partitions[partition] = _Partition()
            self._partitions[partition].tasks.add(task)
            self._p_to_process.add(partition)

        return task