[Qgis-user] Checking WFS / HTTP error codes in pyQGIS / QgsVectorLayer?

John Layt j.layt at lparchaeology.com
Fri Dec 3 08:05:30 PST 2021


Hi,

We have a plugin that runs a background task to download some data from an
external WFS service via QgsVectorLayer. The API is limited to 100 features
per call, requiring us to page our requests, and to 600 calls a minute.

If we make too many calls per minute then we get HTTP 429 warnings in the
OGR log and the download task terminates with incomplete data. The
QgsVectorLayer and QgsVectorDataProvider return isValid() as False and
featureCount() as -2, but hasErrors() is False and errors() is empty. This
is no different than the call failing due to there being no data, so is no
real use.

What I want is to be able to detect the 429 errors and implement a retry
strategy, but there seems no way to access this info? Am I missing the
obvious here? Or am I doomed to using urllib to make the calls manually?

Cheers!

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20211203/2c6524ec/attachment.html>


More information about the Qgis-user mailing list