小编die*_*o_c的帖子

气流回填澄清

我刚刚开始使用Airbnb的气流,而且我仍然不清楚回填是如何/何时完成的.

具体来说,有2个用例让我困惑:

  1. 如果我运行airflow scheduler几分钟,停止它一分钟,然后再重新启动它,我的DAG似乎在前30秒左右运行额外的任务,然后它继续正常(每10秒运行一次).这些额外的任务是"回填"的任务,在早期的运行中无法完成吗?如果是这样,我怎么告诉气流不回填这些任务?

  2. 如果我运行airflow scheduler几分钟,然后运行airflow clear MY_tutorial,然后重新启动airflow scheduler,它似乎运行了一大堆额外的任务.这些任务是否也以某种方式"回填"任务?或者我错过了什么.

目前,我有一个非常简单的dag:

default_args = {
    'owner': 'me',
    'depends_on_past': False,
    'start_date': datetime(2016, 10, 4),
    'email': ['airflow@airflow.com'],
    'email_on_failure': False,
    'email_on_retry': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=5),
    # 'queue': 'bash_queue',
    # 'pool': 'backfill',
    # 'priority_weight': 10,
    # 'end_date': datetime(2016, 1, 1),
}

dag = DAG(
    'MY_tutorial', default_args=default_args, schedule_interval=timedelta(seconds=10))

# t1, t2 and t3 are examples of tasks created by instantiating operators
t1 = BashOperator(
    task_id='print_date',
    bash_command='date', …
Run Code Online (Sandbox Code Playgroud)

airflow

30
推荐指数
2
解决办法
2万
查看次数

为什么烧瓶的jsonify方法很慢?

我正在烧瓶中写一个返回json的API.每个烧瓶功能都是这种形式

from flask import jsonify
@app.route('/getdata')
def get_data():
    data = load_data_as_dict()
    return jsonify(data)
Run Code Online (Sandbox Code Playgroud)

如果我返回大量数据,则对此函数的调用大约需要1.7秒.但是,如果我这样做:

from flask import Response
@app.route('/getdata')
def get_data():
    data = load_data_as_dict()
    data_as_str = json.dumps(data)
    return Response(response=data_as_str, status=200, mimetype="application/json"
Run Code Online (Sandbox Code Playgroud)

...该功能在.05秒左右完成.

谁能告诉我为什么jsonify这么慢?返回原始Flask响应有什么问题吗?

python api performance json flask

15
推荐指数
3
解决办法
4211
查看次数

标签 统计

airflow ×1

api ×1

flask ×1

json ×1

performance ×1

python ×1