[QGIS-Developer] How to deal with time delay in QgsProcessingAlgorithm?
Nils Nolde
nilsnolde at gmail.com
Sat Dec 8 00:42:31 PST 2018
Hi Nyall,
Ok, I wasn't sure if they're being executed in another thread by default.
Then it is weird. I'm not doing anything out of the ordinary I guess.
I'm calling the client from within the algo
<https://github.com/nilsnolde/OSMtools/blob/345f9dce7893453baa80e22067fabdd17852e5ea/ORStools/proc/isochrones_proc.py#L164>'s
processAlgorithm() and the client sleeps on exception here
<https://github.com/nilsnolde/OSMtools/blob/345f9dce7893453baa80e22067fabdd17852e5ea/ORStools/core/client.py#L161>.
But even when it's not sleeping and only requesting, it's freezing the app.
The algo from the branch in the links above works (not much else though
atm), in case anyone wants to see it in action. There is an API key in
that branch, so all ready to go. Will delete the key soon of course. If
you try: best on a (single geometry) point layer with > 200 points.
Anyways, hope someone can clear up the mystery.
Thanks
Nils
On 08.12.18 05:20, Nyall Dawson wrote:
> On Sat, 8 Dec 2018 at 09:14, Nils Nolde <nilsnolde at gmail.com> wrote:
>> Hi,
>>
>> I'd like to extend the openrouteservice API client plugin with a
>> processing provider, but I run into problems implementing an error catch
>> for 'Query limit exceeded' which is usually set to 40 requests/min. I
>> want the plugin to be able to continue requesting when it hits that
>> limit, after waiting the appropriate amount of time.
>>
>> Currently I'm doing the following:
>>
>> - The request is made in a 'client' module. That client module is called
>> by the processing algorithms (e.g. isochrones) whose input feature
>> source can have more than 40 features and likely exceed the minutely limit
>>
>> - When the limit is exceeded, the 'client' module catches the HTTP error
>> and invokes a time.sleep() for (60 - seconds_since_first_request)
>> seconds, and then continues requesting
>>
>> That freezes QGIS obviously, which is not what I want.
>>
>> Any idea how to deal with this? I have no idea how to delay Python
>> execution without freezing the main application..
> By default algorithms are executed in a background thread, so I'm
> surprised to hear that you're getting a freeze here. Did you change
> your algorithm to prevent this background execution? How are you
> launching the algorithm?
>
> Nyall
>
>> Many thanks
>>
>> Nils
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20181208/3e1ac6ca/attachment.html>
More information about the QGIS-Developer
mailing list