File tree Expand file tree Collapse file tree 10 files changed +24
-7
lines changed
Expand file tree Collapse file tree 10 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,14 @@ def retry_after_wait_gen(**kwargs):
5959 exc_info = sys .exc_info ()
6060 if exc_info [1 ] is not None and hasattr (exc_info [1 ], "response" ):
6161 resp = exc_info [1 ].response
62- # Retry-After is an undocumented header. But honoring
63- # it was proven to work in our spikes.
64- sleep_time_str = resp .headers .get ("Retry-After" , "1" )
65- yield math .floor (float (sleep_time_str ))
62+ if resp .status_code == 429 :
63+ # Retry-After is an undocumented header. But honoring
64+ # it was proven to work in our spikes.
65+ sleep_time_str = resp .headers .get ("Retry-After" , "1" )
66+ yield math .floor (float (sleep_time_str ))
6667 else :
6768 # LOGGER.error("retry_after_wait_gen called without a valid exception.")
68- yield 1
69+ yield 0
6970
7071
7172def invalid_token_handler (details ):
@@ -95,7 +96,7 @@ def asana_error_handling(fnc):
9596 )
9697 @backoff .on_exception (
9798 retry_after_wait_gen ,
98- requests .exceptions .HTTPError ,
99+ ( requests .exceptions .HTTPError , requests . exceptions . ConnectionError ) ,
99100 giveup = is_not_status_code_fn ([429 ]),
100101 on_backoff = leaky_bucket_handler ,
101102 jitter = None ,
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ def get_objects(self):
4949 "get_portfolios" ,
5050 workspace = workspace ["gid" ], # Workspace ID
5151 opts = {"owner" : "me" , "opt_fields" : opt_fields },
52+ _request_timeout = self .request_timeout ,
5253 )
5354
5455
@@ -59,6 +60,7 @@ def get_objects(self):
5960 "get_portfolio" ,
6061 portfolio_gid = portfolio ["gid" ],
6162 opts = {"opt_fields" : opt_fields },
63+ _request_timeout = self .request_timeout ,
6264 )
6365
6466 # Add detailed portfolio information to the portfolio object
Original file line number Diff line number Diff line change @@ -61,7 +61,8 @@ def get_objects(self):
6161 response = self .call_api (
6262 projects_api ,
6363 "get_projects" ,
64- opts = {"workspace" : workspace ["gid" ], "opt_fields" :opt_fields }
64+ opts = {"workspace" : workspace ["gid" ], "opt_fields" :opt_fields },
65+ _request_timeout = self .request_timeout ,
6566 )
6667
6768 for project in response ["data" ]:
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ def get_objects(self):
3535 projects_api ,
3636 "get_projects" ,
3737 opts = {"workspace" : workspace ["gid" ], "opt_fields" : opt_fields },
38+ _request_timeout = self .request_timeout ,
3839 )
3940 project_ids = [project ["gid" ] for project in response ["data" ]]
4041
@@ -45,6 +46,7 @@ def get_objects(self):
4546 "get_sections_for_project" ,
4647 project_gid = project_id ,
4748 opts = {"opt_fields" : opt_fields },
49+ _request_timeout = self .request_timeout ,
4850 )
4951 for section in section_response ["data" ]:
5052 yield section
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ def get_objects(self):
8585 projects_api ,
8686 "get_projects" ,
8787 opts = {"workspace" : workspace ["gid" ], "opt_fields" : opt_fields },
88+ _request_timeout = self .request_timeout ,
8889 )
8990 project_ids = [project ["gid" ] for project in response ["data" ]]
9091
@@ -94,6 +95,7 @@ def get_objects(self):
9495 tasks_api ,
9596 "get_tasks" ,
9697 opts = {"project" : project_id },
98+ _request_timeout = self .request_timeout ,
9799 )
98100 for task in task_response ["data" ]:
99101 task_gid = task .get ("gid" )
@@ -104,6 +106,7 @@ def get_objects(self):
104106 "get_stories_for_task" ,
105107 task_gid = task_gid ,
106108 opts = {"opt_fields" : opt_fields },
109+ _request_timeout = self .request_timeout ,
107110 )
108111 for story in story_response ["data" ]:
109112 session_bookmark = self .get_updated_session_bookmark (
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ def get_objects(self):
7474 projects_api ,
7575 "get_projects" ,
7676 opts = {"workspace" : workspace ["gid" ], "opt_fields" : "gid" },
77+ _request_timeout = self .request_timeout ,
7778 )
7879 project_ids = [project ["gid" ] for project in projects_response ["data" ]]
7980
@@ -84,6 +85,7 @@ def get_objects(self):
8485 tasks_api ,
8586 "get_tasks" ,
8687 opts = {"project" : project_id , "opt_fields" : opt_fields },
88+ _request_timeout = self .request_timeout ,
8789 )
8890 for task in tasks_response ["data" ]:
8991 # Fetch subtasks recursively
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def get_objects(self):
3939 tags_api ,
4040 "get_tags" ,
4141 opts = {"workspace" : workspace ["gid" ], "opt_fields" : opt_fields },
42+ _request_timeout = self .request_timeout ,
4243 )
4344 for tag in tag_response ["data" ]:
4445 session_bookmark = self .get_updated_session_bookmark (
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ def get_objects(self):
7070 projects_api ,
7171 "get_projects" ,
7272 opts = {"workspace" : workspace ["gid" ], "opt_fields" : "gid" },
73+ _request_timeout = self .request_timeout ,
7374 )
7475 project_ids = [project ["gid" ] for project in response ["data" ]]
7576
@@ -83,6 +84,7 @@ def get_objects(self):
8384 "opt_fields" : opt_fields ,
8485 "modified_since" : modified_since ,
8586 },
87+ _request_timeout = self .request_timeout ,
8688 )
8789 for task in task_response ["data" ]:
8890 session_bookmark = self .get_updated_session_bookmark (
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ def get_objects(self):
4343 "get_teams_for_workspace" ,
4444 workspace_gid = workspace ["gid" ],
4545 opts = {"opt_fields" : opt_fields },
46+ _request_timeout = self .request_timeout ,
4647 )
4748 for team in teams_response ["data" ]:
4849 # Fetch users for the current team using get_users_for_team
@@ -51,6 +52,7 @@ def get_objects(self):
5152 "get_users_for_team" ,
5253 team_gid = team ["gid" ],
5354 opts = {"opt_fields" : "gid,name,email" },
55+ _request_timeout = self .request_timeout ,
5456 )
5557 team ["users" ] = users_response ["data" ]
5658 yield team
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def get_objects(self):
3939 users_api ,
4040 "get_users" ,
4141 opts = {"workspace" : workspace ["gid" ], "opt_fields" : opt_fields },
42+ _request_timeout = self .request_timeout ,
4243 )
4344 for user in users_response ["data" ]:
4445 yield user
You can’t perform that action at this time.
0 commit comments