Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Appengine管道,如何让函数在管道工作完成后立即执行_Python_Google App Engine_Pipeline - Fatal编程技术网

Python Appengine管道,如何让函数在管道工作完成后立即执行

Python Appengine管道,如何让函数在管道工作完成后立即执行,python,google-app-engine,pipeline,Python,Google App Engine,Pipeline,我尝试添加一个回调函数,该函数在Log2Bq完成后执行。 但我使用pipeline.After或pipeline.inoder都不起作用。在下面的代码示例中,taskqueue将立即执行,而不等待Log2Bq。为了解决这个问题, 我是否需要创建另一个管道来保存taskqueue,以使执行顺序正常工作 class Log2Stat(base_handler.PipelineBase): def run(self, _date): print "start track"

我尝试添加一个回调函数,该函数在Log2Bq完成后执行。 但我使用
pipeline.After
pipeline.inoder
都不起作用。在下面的代码示例中,taskqueue将立即执行,而不等待Log2Bq。为了解决这个问题, 我是否需要创建另一个管道来保存taskqueue,以使执行顺序正常工作

class Log2Stat(base_handler.PipelineBase):
    def run(self, _date):
        print "start track"
        with pipeline.InOrder():
            yield pipelines.Log2Bq()

            print "finish track"
            taskqueue.add(
                url='/worker/update_daily_stat',
                params={
                    "date": str(_date.date())
                }
            )
pipeline.inoorder()
pipeline.After()
仅用于排序管道执行,而不是代码执行

有一个名为finalized的方法,它在写入最后一个输出后立即执行,也就是说,当您的
Log2Bq()
管道完成它的执行时,因此:

class Log2Stat(base_handler.PipelineBase):
    def run(self, _date):
        print "start track"
        yield pipelines.Log2Bq()

    def finalized(self):
        print "finish track"
        taskqueue.add(
            url='/worker/update_daily_stat',
            params={
                "date": str(_date.date())
            }
         )
如果要使用pipeline.inoorder()或pipeline.After(),则应将taskqueue代码包装在其他管道中,并在pipelines.Log2Bq()之后生成它。


谢谢。我终于明白了!!
with pipeline.InOrder():
      yield pipelines.Log2Bq()
      yield pipelines.YourOtherPipeline()