BrokenSegue created this task.
BrokenSegue added a project: Pywikibot.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
**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 rows
There 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 rows
**What 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
TASK DETAIL
https://phabricator.wikimedia.org/T320590
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: BrokenSegue
Cc: Aklapper, BrokenSegue, pywikibot-bugs-list, PotsdamLamb, Jyoo1011,
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS,
Mdupont, JJMC89, Dvorapa, Altostratus, Avicennasis, mys_721tx, Xqt, jayvdb,
Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]