Re: Async HTTP download with Glib event loop doesn't work on windows



Without knowing how AnyEvent works, if the handler involves threads
then calling *any* GTK+ API from different threads than the one that
called `gtk_main()` is going to blow up your application. Even if it
worked in one release, during a specific alignment of planets, or if
you placed the machines in a pentacle drawn in goat blood, there's no
guarantee that it'll keep working. GTK+ simply does *not* support
multi-threaded access of the windowing system resources.

GTK+ and the G* platform has a whole bunch of API to deal with these
cases, like GTask[0]. Sadly, it's not very Perlish because nobody
wrote introspection overrides for it. Additionally, for things like
HTTP requests, there's a whole library called libsoup[1] which
integrates with the GLib main loop.

Ciao,
 Emmanuele.

[0]: https://developer.gnome.org/gio/stable/GTask.html
[1]: https://developer.gnome.org/libsoup/stable/

On 10 March 2017 at 15:27, Peter Juhasz <peter juhasz83 gmail com> wrote:
The plot thickens.

I've got a very helpful tip about Berrybrew (
https://github.com/stevieb9/berrybrew ), which is a Windows analog to
Perlbrew, allowing multiple versions of Strawberry Perl to coexist on the
same system. I've installed Glib (1.305), Gtk2 (1.2498), AnyEvent (7.13),
AnyEvent::HTTP (2.23) on all versons between 5.12 and 5.24, and ran the test
script on all of them. 5.16.3 and below works, 5.18.4 and above fails.

The following test program demonstrates the issue even more dramatically:
##################
#!/usr/bin/perl

use strict;
use warnings;
use feature qw/say/;
use Gtk2 -init;

use AnyEvent;
use AnyEvent::HTTP;

my $w = Gtk2::Window->new();
my $l = Gtk2::Label->new();

$l->set_text("init");
$w->add($l);
$w->show_all();

my $wa; $wa = AnyEvent->timer(after => 2.0, interval => 2.0, cb => sub {
    http_request('GET',
        'http://www.fsz.bme.hu/cgi-bin/ltime',
        sub {
                my ($response_body, $response_headers) = @_;
                $l->set_text($response_body);
        }
    );

    $l->set_text("ready");
});


Gtk2->main();
#######################

On Perl 5.16.3 and below it fetches the data from the network and displays
it in a window, on 5.18.4 and above it hangs.

I've looked at the perldelta docs for 5.18 but nothing obvious stood out.

Now what?

Peter


On Thu, Mar 9, 2017 at 5:32 PM, Brian Manning <cpan xaoc org> wrote:

On Wed, Mar 8, 2017 at 4:58 AM, Peter Juhasz <peter juhasz83 gmail com>
wrote:
Dear Gtk-Perl experts,

We have a legacy Gtk2 application that occasionally has to send HTTP
requests asynchronously.
We've noticed that it hangs on Windows with recent perls.

What was the last versions of Perl/Gtk2/Glib/AnyEvent that worked for
you on Windows?

Finally, my question:
is there any hope that this issue will be fixed, or at least its cause
be
found, or should we abandon this approach entirely?

I'm going to guess that you're the only person trying to do this; you
may want to take that into consideration.

Thanks,

Brian



_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list




-- 
https://www.bassi.io
[@] ebassi [@gmail.com]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]