Steps to replicate the issue (include links if applicable):
- Swallows syntax exception
> from pywikibot import pagegenerators as pg
> generator = pg.WikidataSPARQLPageGenerator("SELECT INVALID SPARQL")
WARNING: Http response status 400
> count = 0
> for _ in generator:
> count += 1
> print(f"we fetched {count} rows")
we fetched 0 rowsThere is no way to get the fact that that WARNING was issued and printed to stderr. This gets a lot worse when a timeout only sometimes happens.
- Swallows timeout exception (for some query timeoutQuery that times out
> generator = pg.WikidataSPARQLPageGenerator(timeoutQuery)
WARNING: Http response status 500
> count = 0
> for _ in generator:
> count += 1
> print(f"we fetched {count} rows")
we fetched 0 rowsWhat happens?:
The SPARQL query fails but there is no way to detect this fact. Code consuming the returned generator will believe that query returned no results when in reality the query never finished execution.
What should have happened instead?:
Optimally an exception would be thrown and could be caught. This likely would break backwards compatibility and so either a new method or a new flag should be added. I need to be able to retry queries that time out and as currently implemented there's no way to do that.
Software version : 7.7.0-87-gbff4621b4
Other information : python-3.8.10