Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await start {} hangs when using HTTP::UserAgent #4659

Closed
p6rt opened this issue Oct 18, 2015 · 10 comments
Closed

await start {} hangs when using HTTP::UserAgent #4659

p6rt opened this issue Oct 18, 2015 · 10 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 18, 2015

Migrated from rt.perl.org#126390 (status was 'resolved')

Searchable as RT126390$

@p6rt
Copy link
Author

p6rt commented Oct 18, 2015

From @Ovid

I was trying to write up a new concurrency examples for a talk when I encountered this​:
05​:20​:34 ~/temp $ time perl6 -MHTTP​::UserAgent -e 'my $url = "http://www.rakudo.org/"; my $ua = HTTP​::UserAgent.new; $ua.get($url)'

real 0m12.382s
user 0m10.374s
sys 0m0.203s
05​:21​:33 ~/temp $ time perl6 -MHTTP​::UserAgent -e 'my $url = "http://www.rakudo.org/"; my $ua = HTTP​::UserAgent.new; $ua.get($url); await start { $ua.get($url) }'

real 0m13.869s
user 0m10.607s
sys 0m0.215s
05​:21​:59 ~/temp $ time perl6 -MHTTP​::UserAgent -e 'my $url = "http://www.rakudo.org/"; my $ua = HTTP​::UserAgent.new; await start { $ua.get($url) }'

# hangs forever unless we do a FIRST $ua.get outside of start {}
The last example just hangs. As far as I can tell, I have to make at least one get($url) call outside of the promise for it to work.
I get the same behavior with LWP​::Simple.
05​:25​:35 ~/temp $ time perl6 -MLWP​::Simple -e 'my $url = "http://www.rakudo.org/"; LWP​::Simple.get($url)'
real 0m9.003suser 0m7.277ssys 0m0.145s05​:28​:50 ~/temp $ time perl6 -MLWP​::Simple -e 'my $url = "http://www.rakudo.org/"; LWP​::Simple.get($url); await start { LWP​::Simple.get($url) }'
real 0m11.003suser 0m7.625ssys 0m0.162s05​:29​:11 ~/temp $ time perl6 -MLWP​::Simple -e 'my $url = "http://www.rakudo.org/"; await start { LWP​::Simple.get($url) }'
# hangs ...
Best,Ovid-- IT consulting, training, specializing in Perl, databases, and agile developmenthttp://www.allaroundtheworld.fr/. 
Buy my book! - http://bit.ly/beginning_perl

@p6rt
Copy link
Author

p6rt commented Oct 18, 2015

From ovid@cpan.org

I forgot to mention this is on OS X Yosemite (10.10.5).

This is perl6 version 2015.09-412-g32d7b08 built on MoarVM version 2015.09-79-gee9fc2b

Cheers,
Ovid

@p6rt
Copy link
Author

p6rt commented Oct 18, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @jonathanstowe

I can confirm this happens on other platforms than OS X.

It is not isolated to HTTP​::UserAgent and happens with LWP​::Simple too.

In both cases according to strace it gets hung up in a futex().

I'm struggling to replicate with bare IO​::Socket​::INET code though.

@p6rt
Copy link
Author

p6rt commented Oct 21, 2015

From @jonathanstowe

And the reason that it couldn't be replicated in IO​::Socket​::INET code is that it isn't the socket apparently​:

<ollej> I'm having an issue when using the URI module inside a Promise. Unless I've used the URI module before awaiting the result, the program never finishes. Using rakudo 2015.09.
<ollej> I've boiled it down to the following example​: await Promise.in(1).then({ say URI.new('http://www.example.com'); });

Which can be reduced to​:

use URI;

await start { say URI.new("http://localhost") };

So IO​::Socket​::INET is off the hook.

On Mon Oct 19 14​:41​:59 2015, jns+bc@​gellyfish.co.uk wrote​:

I can confirm this happens on other platforms than OS X.

It is not isolated to HTTP​::UserAgent and happens with LWP​::Simple too.

In both cases according to strace it gets hung up in a futex().

I'm struggling to replicate with bare IO​::Socket​::INET code though.

@p6rt
Copy link
Author

p6rt commented Oct 21, 2015

From @jonathanstowe

Infact​:

<llfourn> perl6 -MIETF​::RFC_Grammar​::URI -e "await Promise.in(1).then({ require IETF​::RFC_Grammar​::URI });" will hang

On Wed Oct 21 03​:33​:33 2015, jns+bc@​gellyfish.co.uk wrote​:

And the reason that it couldn't be replicated in IO​::Socket​::INET code
is that it isn't the socket apparently​:

<ollej> I'm having an issue when using the URI module inside a
Promise. Unless I've used the URI module before awaiting the result,
the program never finishes. Using rakudo 2015.09.
<ollej> I've boiled it down to the following example​: await
Promise.in(1).then({ say URI.new('http://www.example.com'); });

Which can be reduced to​:

use URI;

await start { say URI.new("http://localhost") };

So IO​::Socket​::INET is off the hook.

On Mon Oct 19 14​:41​:59 2015, jns+bc@​gellyfish.co.uk wrote​:

I can confirm this happens on other platforms than OS X.

It is not isolated to HTTP​::UserAgent and happens with LWP​::Simple
too.

In both cases according to strace it gets hung up in a futex().

I'm struggling to replicate with bare IO​::Socket​::INET code though.

@p6rt
Copy link
Author

p6rt commented Dec 30, 2015

From @zoffixznet

To give an update on this. With Rakudo built on Dec 30, 2015, I no longer get any hangs with neither
perl6 -MURI -e 'await start { say URI.new("http://localhost") };'

nor perl6 -MIETF​::RFC_Grammar​::URI -e "await Promise.in(1).then({ require IETF​::RFC_Grammar​::URI });"

This is on Debian Wheezy. I tried both on 32bit 2-core and 64bit 1-core boxes.

@p6rt
Copy link
Author

p6rt commented Mar 9, 2018

From @dogbert17

On Wed, 30 Dec 2015 09​:12​:25 -0800, cpan@​zoffix.com wrote​:

To give an update on this. With Rakudo built on Dec 30, 2015, I no
longer get any hangs with neither
perl6 -MURI -e 'await start { say URI.new("http://localhost") };'

nor perl6 -MIETF​::RFC_Grammar​::URI -e "await Promise.in(1).then({
require IETF​::RFC_Grammar​::URI });"

This is on Debian Wheezy. I tried both on 32bit 2-core and 64bit 1-
core boxes.

This problem has been fixed. Part of the problem seems to have been the
use of require in a thread, i.e. RT #​126587.

@p6rt
Copy link
Author

p6rt commented Mar 9, 2018

@dogbert17 - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Mar 9, 2018
@p6rt
Copy link
Author

p6rt commented Mar 9, 2018

From @AlexDaniel

FWIW it's not possible to reproduce the issue on older rakudos because it was sweeped under the rug in the URI module itself​: raku-community-modules/URI#21

So yes, #​126587 is a “testneeded” ticket for the underlying issue.

On 2018-03-09 12​:58​:27, jan-olof.hendig@​bredband.net wrote​:

On Wed, 30 Dec 2015 09​:12​:25 -0800, cpan@​zoffix.com wrote​:

To give an update on this. With Rakudo built on Dec 30, 2015, I no
longer get any hangs with neither
perl6 -MURI -e 'await start { say URI.new("http://localhost") };'

nor perl6 -MIETF​::RFC_Grammar​::URI -e "await Promise.in(1).then({
require IETF​::RFC_Grammar​::URI });"

This is on Debian Wheezy. I tried both on 32bit 2-core and 64bit 1-
core boxes.

This problem has been fixed. Part of the problem seems to have been the
use of require in a thread, i.e. RT #​126587.

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant