facebook-python-business-sdk
facebook-python-business-sdk copied to clipboard
Fix AsyncJob.__nonzero__ job complete check
Async calls can return with job['async_percent_completion'] == 100
yet still not be complete. The response looking like:
<AsyncJob> {
"account_id": ".....",
"async_percent_completion": 100,
"async_status": "Job Running",
"id": "6035747473269",
"is_running": true,
"report_run_id": "6035747473269",
"time_ref": 1456266098
}
A subsequent call to .get_result()
would fail with:
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v2.5/.../insights
Params: {}
Status: 400
Response:
{
"error": {
"code": 2601,
"is_transient": true,
"error_subcode": 1815107,
"error_user_msg": "Sorry, the report cannot be loaded successfully. Please check if your job status is completed instead of failed or running before fetching the data.",
"error_user_title": "Loading Async Ads Report Failed",
"message": "Error accessing adreport job.",
"type": "OAuthException",
"fbtrace_id": "E/qCS/IDH7v"
}
}
The actually completed response looks like:
<AsyncJob> {
"account_id": "164313463899989",
"async_percent_completion": 100,
"async_status": "Job Completed",
"id": "6035747473269",
"is_running": true,
"report_run_id": "6035747473269",
"time_completed": 1456266101,
"time_ref": 1456266098
}
This patch also checks for job['async_status'] == 'Job Completed'
for that reason. Although the async_percent_completion
check is irrelevant in light of this.
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!
@rituparnamukherjee can we merge this too?
can we include that in 2.7.2 version? it's pretty critic... cc @daphyFB @JiamingFB
Hi, nonzero is not in 2.7. Do you want to merge back to 2.6, or do you actually want to add those features in 2.7?
I don't see any branch referring to the 2.6 version on this repo (plus it's gonna be pretty quickly deprecated). I will port those changes to 2.7 and add tests then :)