https://code.google.com/p/appengine-pipeline/wiki/GettingStarted#Execution_ordering
I tried to add a callback function which execute after the Log2Bq done.
But it doesn't work either I use pipeline.After
or pipeline.InOrder
. In the following code sample, the taskqueue will execute immediate without waiting for Log2Bq. To fix the issue,
do I need to create another pipeline to hold the taskqueue in order to make the execute order works?
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.InOrder()
and pipeline.After()
are only for ordering pipelines execution, not code execution.
There is a method called finalized, that is executed right after the last output is written, that is when your Log2Bq()
pipeline finish it's execution, so:
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())
}
)
If you want to use pipeline.InOrder() or pipeline.After() you should wrap your taskqueue code in other pipeline and yield it after pipelines.Log2Bq()
with pipeline.InOrder():
yield pipelines.Log2Bq()
yield pipelines.YourOtherPipeline()