[Qgis-user] QgsBlockingNetworkRequest causes SIGSEGV

Frank Broniewski hallo at frankbroniewski.com
Mon May 24 10:28:43 PDT 2021


Hi Richard,

I must admit that I am not sure myself. I have  a script that can communicate 
with the public Web-API of the official luxemburgish geoportal. I use the 
`requests` module in that and it has a nice little command line interface, 
nice for testing and such.

Then I read in a post from Nyall Dawson [1] that QgsBlockingNetworkRequest is 
a "nearly drop-in replacement for the requests module". So I thought I would 
give it a go and remove the dependency on the requests module. In addition, 
having found the unittest script [2] I was pretty certain that it should work. 
But my knowledge of everything Qt is not that great, so there's lots of room 
for misconception on my side here.

It is not the end of the world if QgsBlockingNetwortRequest is only usable 
from inside QGIS, but I was certainly surprised to see it crash like this. But 
then I will have to find out how I can run my tests against the API then when a 
QGIS environment is a requirement here.

And yes, I can confirm that using QgsBlockingNetwortRequest from within QGIS, 
the python console is sufficient, works fine as intended.

Thanks a lot for your feedback and the small plugin,
Frank


[1] https://lists.osgeo.org/pipermail/qgis-user/2019-November/044364.html
[2] https://github.com/qgis/QGIS/blob/master/tests/src/python/
test_qgsblockingnetworkrequest.py

Am Sonntag, 23. Mai 2021, 21:23:14 CEST schrieb Richard Duivenvoorde:
> Hi Frank,
> 
> Moving this to dev list as I think that is more appropriate for this
> question.
> 
> I can easily replicate your issue (on Debian Testing, see below the
> coredump.txt)
> 
> BUT: are you sure you want to use it outside of QGIS in a standalone script?
> Because I think these things will need some kind of Qt-Application to
> run... (as the Application is responsible for stuff like NetWorkProxies,
> and has the actual 'NetWorkAccessManager'?). But all just guessing...
> 
> Using your code in a minimal HelloWorldPlugin (attached), it just works.
> (the url I'm using just sents 'ok' as text).
> 
> So: I would not try to run it in a standalone script without a QGIS
> application context, but in a plugin it 'works'?
> 
> 
> Regards,
> 
> Richard Duivenvoorde
> 
> 
> 
> 
> 
>            PID: 18825 (gnome-shell)
>            UID: 1000 (richard)
>            GID: 1000 (richard)
>         Signal: 11 (SEGV)
>      Timestamp: Sat 2021-03-06 16:16:12 CET (3min 52s ago)
>   Command Line: /usr/bin/gnome-shell
>     Executable: /usr/bin/gnome-shell
>  Control Group:
> /user.slice/user-1000.slice/user at 1000.service/session.slice/org.gnome.Shell
> @wayland.service Unit: user at 1000.service
>      User Unit: org.gnome.Shell at wayland.service
>          Slice: user-1000.slice
>      Owner UID: 1000 (richard)
>        Boot ID: 4aaa450c98ed47b299254a234e463620
>     Machine ID: df76fc45bc594c71b48c4eb87da1774e
>       Hostname: oost
>        Storage:
> /var/lib/systemd/coredump/core.gnome-shell.1000.4aaa450c98ed47b299254a234e4
> 63620.18825.1615043772000000.zst Message: Process 18825 (gnome-shell) of
> user 1000 dumped core. ················
>                 Stack trace of thread 18825:
>                 #0  0x00007fe88cf6003d g_type_check_instance
> (libgobject-2.0.so.0 + 0x3503d) #1  0x00007fe88cf50883
> g_signal_handler_disconnect (libgobject-2.0.so.0 + 0x25883) #2 
> 0x00007fe88cf42eef n/a (libgobject-2.0.so.0 + 0x17eef) #3 
> 0x00007fe88ce2dfae n/a (libglib-2.0.so.0 + 0x31fae) #4  0x00007fe88cf440a3
> g_object_unref (libgobject-2.0.so.0 + 0x190a3) #5  0x00007fe88d1c1df8 n/a
> (libgnome-shell.so + 0x21df8) #6  0x00007fe88cf440a3 g_object_unref
> (libgobject-2.0.so.0 + 0x190a3) #7  0x00007fe88c546c7e n/a (libgjs.so.0 +
> 0x47c7e) #8  0x00007fe88c546d5a n/a (libgjs.so.0 + 0x47d5a) #9 
> 0x00007fe88c542588 n/a (libgjs.so.0 + 0x43588) #10 0x00007fe88c542673 n/a
> (libgjs.so.0 + 0x43673) #11 0x00007fe88aa3681c n/a (libmozjs-78.so.0 +
> 0x65381c) #12 0x00007fe88aa073be n/a (libmozjs-78.so.0 + 0x6243be) #13
> 0x00007fe88aa10c02 n/a (libmozjs-78.so.0 + 0x62dc02) #14 0x00007fe88aa18ac5
> n/a (libmozjs-78.so.0 + 0x635ac5) #15 0x00007fe88aa330b6 n/a
> (libmozjs-78.so.0 + 0x6500b6) #16 0x00007fe88aa337dc n/a (libmozjs-78.so.0
> + 0x6507dc) #17 0x00007fe88aa33a6c n/a (libmozjs-78.so.0 + 0x650a6c) #18
> 0x00007fe88aa33d25 n/a (libmozjs-78.so.0 + 0x650d25) #19 0x00007fe88c55dc1f
> n/a (libgjs.so.0 + 0x5ec1f) #20 0x00007fe88ce4e8f4 n/a (libglib-2.0.so.0 +
> 0x528f4) #21 0x00007fe88ce4dd6f g_main_context_dispatch (libglib-2.0.so.0 +
> 0x51d6f) #22 0x00007fe88ce4e118 n/a (libglib-2.0.so.0 + 0x52118) #23
> 0x00007fe88ce4e40b g_main_loop_run (libglib-2.0.so.0 + 0x5240b) #24
> 0x00007fe88c27627e meta_init (libmutter-7.so.0 + 0xc529e) #25
> 0x00007ffd8eec1f9c n/a (n/a + 0x0)
>                 #26 0x455059545f4e4f49 n/a (n/a + 0x0)
> 
> On 5/22/21 3:32 PM, Frank Broniewski wrote:
> > Hi all,
> > 
> > I am trying to replace the `requests` module with
> > QgsBlockingNetworkRequest to remove a potentially unnecessary dependency
> > from my QGIS plugin. But I am having trouble using it so far as Python
> > crashes on the command line with a SIGSEGV all the time. First of all,
> > things work from within the QGIS Python shell. But not from the command
> > line outside of QGIS.
> > 
> > I am running Fedora 34 KDE spin, but I also tested on Ubuntu 20.04 with
> > the
> > same failure. It is rather simple to reproduce on my end:
> > 
> > 1) open a Python3 shell
> > 2) >>> import qgis
> > 
> >>>> from qgis.core import QgsBlockingNetworkRequest as bnr
> >>>> r = bnr()
> > 
> > fish: Job 1, 'python' terminated by signal SIGSEGV (Adressbereichsfehler)
> > 
> > I did look at the unittest Testcases  [1] for the class, e.g the
> > testFetchEmptyUrl class method and do not see anything that I could have
> > changed to avoid the SIGSEGV.
> > 
> > So, can I not use QgsBlockingNetworkRequest outside of QGIS or am I just
> > missing something?
> > 
> > Any tips are greatly appreciated,
> > Frank
> > 
> > 
> > [1] https://github.com/qgis/QGIS/blob/master/tests/src/python/
> > test_qgsblockingnetworkrequest.py
> > 
> > 
> > _______________________________________________
> > Qgis-user mailing list
> > Qgis-user at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user






More information about the Qgis-user mailing list