__init__.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:pycos 作者: pgiri 项目源码 文件源码
def async_task(self, target, *args, **kwargs):
        """Must be used with 'yield', as
        'val = yield pool.async_task(target, args, kwargs)'.

        @task is task where this method is called.

        @target is function/method that will be executed asynchronously in a
        thread.

        @args and @kwargs are arguments and keyword arguments passed to @target.

        This call effectively returns result of executing
        'target(*args, **kwargs)'.
        """

        if not self._scheduler:
            self._scheduler = Pycos.scheduler()
        task = Pycos.cur_task(self._scheduler)
        # assert isinstance(task, Task)
        # if arguments are passed as per Thread call, get args and kwargs
        if not args and kwargs:
            args = kwargs.pop('args', ())
            kwargs = kwargs.pop('kwargs', kwargs)
        task._await_()
        self._task_queue.put((task, target, args, kwargs))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号