[ https://issues.apache.org/jira/browse/AIRFLOW-4238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17034690#comment-17034690 ]
Colin Ingarfield edited comment on AIRFLOW-4238 at 2/11/20 6:20 PM: -------------------------------------------------------------------- Can you explain the need for replace_microseconds? Runs triggered manually via the UI do not strip the microseconds. But when triggered via API they are stripped. Before I hack around this restriction I'd like to understand why microseconds are removed. Thanks! was (Author: colini): Can you explain the need for replace_microseconds? Runs triggered manually via the UI do not strip the microseconds. But when triggered via API they are stripped? Before I hack around this restrictions I'd like to understand why microseconds are removed. Thanks! > Experimental API sometimes responds with Bad Request > ---------------------------------------------------- > > Key: AIRFLOW-4238 > URL: https://issues.apache.org/jira/browse/AIRFLOW-4238 > Project: Apache Airflow > Issue Type: Bug > Components: api > Affects Versions: 1.10.2 > Reporter: Roger Lahaije > Priority: Minor > > We wanted to use the Airflow api to start Dag runs. > During implementation we notices the API sometimes responded with error 400 > bad request. > The bad request appear to happen when calls are made fast after oneanother. > > The following code can reproduce the bad requests > {code:java} > import requests > import json > from datetime import datetime > start_time = datetime.now() > def millis(): > dt = datetime.now() - start_time > ms = (dt.days * 24 * 60 * 60 + dt.seconds) * 1000 + dt.microseconds / > 1000.0 > return round(ms) > url = f'http://localhost/api/experimental/dags/some dag/dag_runs' > for i in range(1, 40): > r = requests.post(url, json={'conf': {'run_task': 1}}) > print(f"{millis()} {r.status_code}") > sleep(0.4) > >> results > 132 200 > 561 400 > 1006 200 > 1425 400 > 1870 200 > 2295 400 > 2738 200 > 3171 400 > 3594 400 > 4039 200 > ...{code} > > It looks like it's only possible to call the api a maximum of once a second, > which is probably due to the fact dags can only be started once a second. > > Is there any way we can call the API more than 1 time a second? -- This message was sent by Atlassian Jira (v8.3.4#803005)