File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ def fetch_all_pages(
1010 """Returns an iterator that calls fetch_page with an offset that we increment by the number of pages fetched. Stop if page returns empty list.
1111
1212 :param fetch_page: a function that makes an api call to fetch a page of results (using zero-based offset)
13- :param get_page: a function that extracts the page from the response
13+ :param get_page: a function that extracts the page from the response which should be a list
1414 """
1515
1616 def fetch_all_pages (* args , ** kwargs ) -> Iterator [List [Any ]]:
@@ -21,7 +21,7 @@ def fetch_all_pages(*args, **kwargs) -> Iterator[List[Any]]:
2121 if recs > rec_limit :
2222 # Don't want to DOS ourselves...
2323 raise Exception (
24- f"fetch_all_pages({ name } ): fetched more than { rec_limit } items . Consider using adding or adjusting a filter to reduce the number of items fetched."
24+ f"fetch_all_pages({ name } ): fetched { recs } records which is more than the limit: { rec_limit } . Consider adding or adjusting a filter to reduce the total number of items fetched."
2525 )
2626 try :
2727 response = fetch_page (
@@ -31,13 +31,13 @@ def fetch_all_pages(*args, **kwargs) -> Iterator[List[Any]]:
3131 )
3232 except Exception as err :
3333 raise Exception (
34- f"Failed fetching for { name } for offset={ page_count - 1 } "
34+ f"Failed fetching for { name } for offset={ page_count - 1 } (records fetched so far: { recs } ) "
3535 ) from err
3636 try :
3737 page = get_page (response )
3838 except Exception as err :
3939 raise Exception (
40- f"get_page failed to extract page from response for { name } for offset={ page_count - 1 } "
40+ f"get_page failed to extract page from response for { name } for offset={ page_count - 1 } (records fetched so far: { recs } ) "
4141 ) from err
4242 if len (page ) == 0 :
4343 break
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def never_ending(*args, **kwargs):
8585 results += page
8686
8787 # assert
88- assert "fetched more than 20000 items " in str (exc_info )
88+ assert "more than the limit: 20000 " in str (exc_info )
8989
9090
9191def test_fetch_all_pages_handle_error ():
You can’t perform that action at this time.
0 commit comments