Travis-CI and Rakudo seem to be a bit unstable
Hi, In addition to me breaking my own code, it seems that Travis-CI and Rakudo are rather fragile together. Occasionally my tests fail due to failures in the prerequisites. This failed due to LWP::Simple failing https://travis-ci.org/szabgab/Perl6-Maven/jobs/215147392 even though 20 min earlier it worked: https://travis-ci.org/szabgab/Perl6-Maven/builds/215143736 Yesterday Bailador failed: https://travis-ci.org/szabgab/Perl6-Maven/jobs/214981400 even though it worked a few minutes earlier and a few minutes later. As far as I can tell neither LWP::Simple nor Bailador changed during that time. Have you encountered similar issues? Am I misreading something? regards Gabor
Re: Failed to open file .. too many open files
I still get the same error. I just found another case of slurp-rest which might have been the cause but it might be good time to look at the few other cases of "open" in my code. (And later maybe also the code of Bailador itself.) I tried to read more about how I am supposed to close file handles in Perl 6, but the explanation I found didn't help me. I opened this ticket https://github.com/perl6/doc/issues/1258 asking for further clarification. Anyway here is another code snippet from my code: for open("$.source_dir/authors.txt").lines -> $line { ... } Do I need to close this myself? Can I rely on Perl closing it? If I open a file for reading like this: sub f { my $fh = open $file, :r; LEAVE $fh.close; for $fh.lines -> $line { } } Is that the correct way to put the LEAVE in? Should it be immediately after the open statement? And for writing? sub write { my $fh = open $file, :w; LEAVE $fh.close; $fh.print("text"); } regards Gabor
Re: Perl 6 docs
On Sat, 25 Mar 2017 16:49:04 +0100 Gabor Szabo wrote: > https://github.com/perl6/doc/issues/1257 Thanks for clarifying!
Re: Failed to open file .. too many open files
On Sat, Mar 25, 2017 at 8:42 PM, Elizabeth Mattijsen wrote: > $file.IO.slurp and slurp($file) are basically the same. > > $handle.slurp-rest does *not* close the handle, as another process might > still be writing to it, so you could do another .slurp-rest. > > > To get back to your original code: > >get '/atom' => sub { >my $path = $.meta ~ request.path; >return open($path).slurp-rest; >} > > I would write that as: > >get '/atom' => sub { slurp $.meta ~ request.path } > > Should you wind up with an opened handle, could could use a LEAVE phaser to > make sure the handle gets closed: > >get '/atom' => sub { >LEAVE $.meta.handle.close; >return $.meta.handle.slurp-rest; >} > Thanks. I've converted all those slurp-rest calls so slurp calls. I am not sure why did I have the slurp-rest in there. That code seems to be at least 2 years old. Anyway, thanks for the explanation. Gabor
Re: Failed to open file .. too many open files
$file.IO.slurp and slurp($file) are basically the same. $handle.slurp-rest does *not* close the handle, as another process might still be writing to it, so you could do another .slurp-rest. To get back to your original code: get '/atom' => sub { my $path = $.meta ~ request.path; return open($path).slurp-rest; } I would write that as: get '/atom' => sub { slurp $.meta ~ request.path } Should you wind up with an opened handle, could could use a LEAVE phaser to make sure the handle gets closed: get '/atom' => sub { LEAVE $.meta.handle.close; return $.meta.handle.slurp-rest; } HTH, Liz = > On 25 Mar 2017, at 17:12, Gabor Szabo wrote: > > Oh so you say that's indeed a bug in my code. That's a relief. Thanks! > > > As I can see I had some $file.IO.slurp and some of the slurp-rest ones. > > What is the difference between $file.IO.slurp and slurp($file) ? > Is the latter just an alias for the former? > > Gabor > > > On Sat, Mar 25, 2017 at 4:54 PM, Timo Paulssen wrote: >> i highly suggest you slurp instead of open + slurp-rest, because that >> will automatically close the file for you, too. >> >> other than that, you can pass :close to the slurp-rest method and it'll >> also close the file. >> >> if you're not closing the files you're opening, you'll be relying on the >> garbage collector to do file handle closing for you, which is >> nondeterministic and a bad idea in general. >> >> HTH >> - Timo
Re: Can this OR be shortened?
Apparently there is an '&&' for regular expressions. Perhaps "longest intersection" which will always be the same as "first intersection", intersections being what they are? > '===word up!' ~~ / \w+ && <[j..r]>+ / or > '===word up!' ~~ / \w+ & <[j..r]>+ / or
Re: Can this OR be shortened?
On Fri, Mar 24, 2017 at 10:45 PM, Brad Gilbert wrote: > Basically use | in regexes unless you need ||. There's been some discussion, here and in IRC, of the | form interacting in ways that are correct but which people often don't expect. This can result in match failures or unexpected slowness. My takeaway is there's no simple-minded "do this" or "do this if/unless" rule as yet. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: Failed to open file .. too many open files
Oh so you say that's indeed a bug in my code. That's a relief. Thanks! As I can see I had some $file.IO.slurp and some of the slurp-rest ones. What is the difference between $file.IO.slurp and slurp($file) ? Is the latter just an alias for the former? Gabor On Sat, Mar 25, 2017 at 4:54 PM, Timo Paulssen wrote: > i highly suggest you slurp instead of open + slurp-rest, because that > will automatically close the file for you, too. > > other than that, you can pass :close to the slurp-rest method and it'll > also close the file. > > if you're not closing the files you're opening, you'll be relying on the > garbage collector to do file handle closing for you, which is > nondeterministic and a bad idea in general. > > HTH > - Timo
Re: Failed to open file .. too many open files
i highly suggest you slurp instead of open + slurp-rest, because that will automatically close the file for you, too. other than that, you can pass :close to the slurp-rest method and it'll also close the file. if you're not closing the files you're opening, you'll be relying on the garbage collector to do file handle closing for you, which is nondeterministic and a bad idea in general. HTH - Timo
Re: Perl 6 docs
https://github.com/perl6/doc/issues/1257
Failed to open file .. too many open files
The Perl 6 Maven site runs on Bailador. I've just updated the Rakudo underneath to 2017.01 and it seemed to be working fine, but after a while it started crashing with this error message: Failed to open file /home/gabor/work/perl6maven-live.com/main.json: too many open files in sub at /home/gabor/work/Perl6-Maven/lib/Perl6/Maven.pm6 (Perl6::Maven) line 26 in block at /home/gabor/rakudo-star-2017.01/install/share/perl6/site/sources/A80D3EE41ED647143B6A367AAE142A5967A850D7 (Bailador::Route) line 57 in method recurse-on-routes at /home/gabor/rakudo-star-2017.01/install/share/perl6/site/sources/A80D3EE41ED647143B6A367AAE142A5967A850D7 (Bailador::Route) line 56 in method dispatch at /home/gabor/rakudo-star-2017.01/install/share/perl6/site/sources/06F75D046213CAD92B84F66E5F161C084878D0C3 (Bailador::App) line 84 in block at /home/gabor/rakudo-star-2017.01/install/share/perl6/site/sources/06F75D046213CAD92B84F66E5F161C084878D0C3 (Bailador::App) line 77 I've tried to reproduce the problem by running curl against the local version of the application, but so far, after a few hundred requests, I have not encountered the problem. line 26 in the Maven.pm6 file looks like this: get '/atom' => sub { my $path = $.meta ~ request.path; return open($path).slurp-rest; } I wonder if you have any idea what could be the source of this problem? The full source of the application is here: https://github.com/szabgab/Perl6-Maven/ regards Gabor
Re: Perl 6 docs
Hi Gabor, On Sat, 25 Mar 2017 13:36:31 +0100 Gabor Szabo wrote: > When I search for %INC at https://docs.perl6.org/ it offers "%INC (Perl 5)" > but when I search for the more common @INC > Your sentence appears to be cut in the middle - I cannot understand it. Can you clarify? > Luckily the former leads to > https://docs.perl6.org/language/5to6-perlvar which also has > information on the latter, but it would be nice if that was also > recognized in the search box. > > Gabor
Re: Using Rakudo Start on OSX using the .dmg
These notes are already available in the README.txt file that is in the .dmg Regards. On Sat, Mar 25, 2017 at 4:54 AM, Gabor Szabo wrote: > Hi, > > I just tried to use the .dmg version of Rakudo Star. > I might not be the typical Mac user as I spent quite some time trying to > figure > out what do I need to do in order to start using it after the installation. > > In the end I found that it was installed to /Applications/Rakudo > > Then I added these to my .bash_profile: > > export RAKUDO=/Applications/Rakudo > export PATH=$RAKUDO/bin:$RAKUDO/share/perl6/site/bin/:$PATH > export PERL6LIB=$RAKUDO/share/perl6/site/lib/ > > reloaded it and then I could use it. > > Maybe some notes like this could be added to > http://rakudo.org/how-to-get-rakudo/ > > regards >Gabor -- Will "Coke" Coleda
Re: Perl 6 docs
Please open an issue at https://github.com/perl6/doc/issues so it gets tracked, thanks! On Sat, Mar 25, 2017 at 8:36 AM, Gabor Szabo wrote: > When I search for %INC at https://docs.perl6.org/ it offers "%INC (Perl 5)" > but when I search for the more common @INC > > Luckily the former leads to > https://docs.perl6.org/language/5to6-perlvar which also has > information on the latter, but it would be nice if that was also > recognized in the search box. > > Gabor -- Will "Coke" Coleda
Re: Can this OR be shortened?
On 25/03/17 12:53, Tom Browder wrote: > On Fri, Mar 24, 2017 at 10:36 PM, Timo Paulssen wrote: >> I seem to recall you asked about performance recently >> >> the regex engine has a significant overhead. > ... > > Isn't that somewhat mitigated by defining regex or token constants for reuse? > > -Tom The overhead is from starting up and finishing a regex match. Creating the Match object is quite expensive, for example. all regexes are compiled into code objects, of course.
Perl 6 docs
When I search for %INC at https://docs.perl6.org/ it offers "%INC (Perl 5)" but when I search for the more common @INC Luckily the former leads to https://docs.perl6.org/language/5to6-perlvar which also has information on the latter, but it would be nice if that was also recognized in the search box. Gabor
Re: Can this OR be shortened?
On Fri, Mar 24, 2017 at 10:36 PM, Timo Paulssen wrote: > I seem to recall you asked about performance recently > > the regex engine has a significant overhead. ... Isn't that somewhat mitigated by defining regex or token constants for reuse? -Tom
Re: Can this OR be shortened?
On 25/03/17 06:15, ToddAndMargo wrote: >> while || tries the left side first, then the right side. >> Basically use | in regexes unless you need ||. > > Would this be the logical AND equivalent? > > if $Terminal ~~ /xterm && linux/ {} > > Thank you! > > -T > There is no &&, but there is &. the regex /xterm & linux/ would only match if there were the strings "xterm" and "linux" in the exact same place in a string, which is impossible as far as i know.
Re: Can this OR be shortened?
On Sat, Mar 25, 2017 at 1:15 AM, ToddAndMargo wrote: > Would this be the logical AND equivalent? > > if $Terminal ~~ /xterm && linux/ {} Nope! I tried it out. -y -y On Sat, Mar 25, 2017 at 7:31 AM, yary wrote: > On Sat, Mar 25, 2017 at 1:15 AM, ToddAndMargo wrote: >> On 03/24/2017 07:45 PM, Brad Gilbert wrote: >>> >>> All of these should work >>> >>> if $Terminal ~~ /xterm/ | /linux/ {} >>> if $Terminal ~~ /xterm | linux/ {} >>> if $Terminal ~~ /xterm || linux/ {} >>> >>> Note that | in a regex tries both sides as if in parallel, and goes >>> for the longest, >> >> >> Hi Brad, >> >> What do you mean by longest? > > > my $a = 'Bart sez cowabunga!'; > > # matches cowabunga because that's the longest match > $a ~~ / cow | cowabunga /; > say $/; # "cowabunga" > > # matches cow because it is the first alternation > $a ~~ / cow || cowabunga /; > say $/; # "cow" > > This is useful in writing parsers- when given a choice of keywords > that have the same prefix, longest match will find the keyword people > expect regardless of the order of the alternations. Keeps people from > having to remember to also search for a word boundary at the end, > makes it easier to write bug-free grammars. > > -y
Re: Can this OR be shortened?
On Sat, Mar 25, 2017 at 1:15 AM, ToddAndMargo wrote: > On 03/24/2017 07:45 PM, Brad Gilbert wrote: >> >> All of these should work >> >> if $Terminal ~~ /xterm/ | /linux/ {} >> if $Terminal ~~ /xterm | linux/ {} >> if $Terminal ~~ /xterm || linux/ {} >> >> Note that | in a regex tries both sides as if in parallel, and goes >> for the longest, > > > Hi Brad, > > What do you mean by longest? my $a = 'Bart sez cowabunga!'; # matches cowabunga because that's the longest match $a ~~ / cow | cowabunga /; say $/; # "cowabunga" # matches cow because it is the first alternation $a ~~ / cow || cowabunga /; say $/; # "cow" This is useful in writing parsers- when given a choice of keywords that have the same prefix, longest match will find the keyword people expect regardless of the order of the alternations. Keeps people from having to remember to also search for a word boundary at the end, makes it easier to write bug-free grammars. -y
Using Rakudo Start on OSX using the .dmg
Hi, I just tried to use the .dmg version of Rakudo Star. I might not be the typical Mac user as I spent quite some time trying to figure out what do I need to do in order to start using it after the installation. In the end I found that it was installed to /Applications/Rakudo Then I added these to my .bash_profile: export RAKUDO=/Applications/Rakudo export PATH=$RAKUDO/bin:$RAKUDO/share/perl6/site/bin/:$PATH export PERL6LIB=$RAKUDO/share/perl6/site/lib/ reloaded it and then I could use it. Maybe some notes like this could be added to http://rakudo.org/how-to-get-rakudo/ regards Gabor