The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-07-20

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:27 mattp_ jberger: well hypothetically Mojo::Delay could be leaking memory, its just hidden in his example
00:30 mattp_ im not sure what the best tool for identifying that is, maybe something here https://metacpan.org/pod/Devel::Gladiator#SEE-ALSO
00:31 jberger mattp_: the example would be insufficient to show that though
00:31 jberger the demo the OP gave would certainly take more memory at the end than the start
00:33 mattp_ jberger: the measuring of memory usage yes, but if you have dangling scalars not associated with the objects youve created or cycles in your objects mem will leak
00:34 jberger why would you suspect memory leaks given that example though?
00:34 jberger sure there might be any bug in any given code anywhere :-P
00:35 jberger the demo given is a rather common usage, if there were leaks we would have seen them by now (we get leak reports sometimes, they are much more complicated than that one)
00:36 mattp_ sure. likely in his reduction he removed the bug in his code that was causing his leak :)
00:36 jberger if he ever had a leak
00:36 jberger which I'm not sure of
00:39 jberger I've added a little note, just for completeness
00:53 ningu why does Mojo::Server::Prefork have the accepts attribute? does it shut down workers after a fixed number of connections because of the possibility of leaks?
00:56 dvinciguerra_ joined #mojo
00:59 jberger ningu: basically, yes
00:59 jberger set it to 0 if you don't want that
01:00 ningu it's fine, I was just making sure
01:00 ningu is there a common way people monitor for leaks of that sort?
01:00 ningu I don't know/remember how people remove memory leaks in long-running perl apps
01:00 ningu I mostly just know how to avoid them e.g. with weaken
01:01 ningu but not how to detect existing one
01:01 ningu s
01:01 jberger its best to avoid them if you know how to spot one visually that way
01:01 jberger Devel::Cycle is useful if you know approximately where one is
01:01 ningu how about detecting whether there are any to be worried about? presumably you can track a worker's memory use over time
01:02 ningu I suppose that part is not perl-specific
01:02 jberger right
01:02 jberger that's your first clue
01:02 ningu I was more worried about this in node.js with all the callbacks (perl code is sync currently)
01:03 preaction node has garbage collection
01:03 ningu yeah, but people still manage to get leaks
01:04 preaction using memory isn't leaking it. if they're holding on to references they don't need, they should stop
01:09 Vitrifur joined #mojo
02:02 lluad joined #mojo
02:35 ivi joined #mojo
02:39 noganex_ joined #mojo
02:49 mikef joined #mojo
02:51 mikef Memory leak occur when server is using SSL connection. Mojolicious version is 7.0, OS is debian 8, openssl is latest.
02:53 mikef openssl is using version 1.0.1t-1+deb8u2
02:54 mikef When using plain text connection, no memory leak.
02:56 mikef reproduce by using apache benchmark program to send thousands of request for a static page.
03:29 mikef IO::Socket::SSL is at 2.033
03:33 mikef perl is version 5.22.0 installed by perlbrew
03:54 inbioz joined #mojo
04:34 zivester joined #mojo
04:58 anton joined #mojo
05:10 Kripton joined #mojo
05:44 inbioz joined #mojo
06:13 Kripton joined #mojo
06:48 dod joined #mojo
06:52 dod joined #mojo
07:00 cuechan joined #mojo
07:08 Dandre joined #mojo
07:11 Vandal joined #mojo
07:35 trone joined #mojo
07:40 punter joined #mojo
07:58 cpan_mojo Mojolicious-Plugin-Mason1Renderer-0.03 by ASIMON https://metacpan.org/release/ASIMON/Mojolicious-Plugin-Mason1Renderer-0.03
08:17 AndrewIsh joined #mojo
08:51 dotan joined #mojo
08:54 cuechan joined #mojo
08:59 jasanj joined #mojo
09:02 jasanj after i use $c->render(foo => 1) to render a.html.ep file, the variable $foo can be access in a.html.ep
09:03 ksmadsen joined #mojo
09:04 jasanj but i found it also exist(but undefined) in the following render, for example $c->render(bar=>2), will render b.html.ep, if i write % if ( defined $foo ) { .. } in b.html.ep, it will not got any error
09:05 jasanj but i never defined( i meand use my or our to initilize) $foo in b.html.ep
09:45 nic jasanj: It's hard to tell what you're trying to say, but it sounds like you're adding it to your stash
09:45 nic Distill it down to a minimal executable example so we can see what you're getting at
09:53 jasanj nic: under strict perl, a variable without decleared by my or our can't be use. Mojo::Template is use strict by default. so if i use a variable $foo in template which is not pre-defined or stashed by $c->render(foo => xx), it will got compiling fail, right ?
09:54 nic There are multiple ways to put things in the stash
09:55 jasanj yes, i know that, like $c->stash()
09:55 nic Not sure it's useful guessing the implementation.  The code is very readable, but an example would show us what you're trying to say
09:56 nic (using 'inline' is also great for producing one-liners for this kind of thing)
09:58 jasanj it's a little hard to give you a example, cause it appeared on my $work
09:58 jasanj what do you mean 'inline' ?
10:04 nic nm
10:05 Atog i'm trying to rr
10:05 Atog *run an app under nginx behind a location using proxy path
10:06 Atog problem is i'm generation the urls without that location so it always tries to go to the document root
10:06 Atog is there a way to update the base url or something depending on where the petition goes?
10:17 punter joined #mojo
10:20 nic Atog: if you search the wiki for 'nginx' you might see useful pointers.  I think there might be notes in the Cookbook too
10:27 Atog yeah that "rewrite the base path" stuff seems what i need, already toying with it
10:27 nic yeah, that sounds familiar
10:28 Atog had a typo in my previous searches so never got a result, sorry!
10:28 nic easily done
10:53 jamesaxl joined #mojo
11:04 tchaves joined #mojo
11:15 tchaves joined #mojo
11:23 che-quest joined #mojo
11:48 meshl joined #mojo
11:59 meshl joined #mojo
12:15 Atog now i'm using $self->req->url->base->path->parts->[0] to get the base path of my app, is there any other shorter/clever way to get it?
12:21 Atog nevermind, just reading about the url_for method
12:24 ashimema anyone able to shed some light on my total misunderstanding of callbacks https://ssl.thorsen.pm/paste/c55ac8e4dcdb
12:27 kid51 joined #mojo
12:32 batman ashimema: you can't pass the same $cb to both methods
12:32 batman you're not in control of which one calls it
12:32 batman use a Mojo::IOLoop->delay() which calls both methods and then call $cb in the last callback
12:33 batman "in the last step"
12:33 * ashimema digests
12:35 ashimema confused by the 'not in control of which one calls it'
12:35 * ashimema feels stupid today
12:35 ashimema surely the $c->$cb is the calling it>
12:36 * ashimema is sure he's missed someone rather trivial in his understanding here
12:36 batman so... you're passing on $cb to both _list_get() and _role_check() right?
12:37 ashimema yup
12:37 batman so that means that both of those methods at some point will call $cb. right?
12:37 ashimema but isn't this code synchronous
12:37 batman but you probably just want $cb to be called once, and not twice..?
12:38 ashimema I do indeed
12:38 ashimema I expected the first one to call $cb and processing to stop there
12:38 batman ah. right. this code looks weird... why are you passing in $cb and at the same time expecting a result?
12:38 batman yeah. i think you're missing out on something basic here :(
12:39 ashimema let me throw together the working example i'm attempting to refactor ;
12:39 ashimema might make more sense that way.
12:39 ptolemarch joined #mojo
12:40 ashimema https://ssl.thorsen.pm/paste/1c7eb44c8b0f
12:41 ashimema So.. what I was trying to do was make my code a bit more DRY
12:41 ashimema I often do 'check for list, return error if not exist.. otherwise continue'
12:41 ashimema so I wanted to factor that bit out so I can share it between routines in the Controller
12:42 batman ah. sorry. it looks fine actually :/
12:42 ashimema the refactored one?
12:42 ashimema the original works well
12:43 ashimema basically.. I'm confused as to why.. even when I can prove I've entered the unless() block the cb never seems to fire and prevent further processing
12:44 ashimema I think my 'return' is wrong somewhere along the line
12:44 batman i think the problem is that when you do $c->$cb($response, 404); then the result (whatever that is) is assigned to $listResult and the code continues running
12:45 ashimema ooh..
12:46 batman ashimema: https://ssl.thorsen.pm/paste/55d85953fb36
12:46 ashimema the 'result' of $c->$cb is a Mojo::IOLoop::Delay object
12:46 mlen108 joined #mojo
12:46 ashimema aha..
12:46 ashimema excellent
12:46 ashimema thanks batman
12:47 batman yeah, but it's kind of undefined what the return value should be. don't trust it to be Mojo::IOLoop::Delay for ever
12:47 zivester joined #mojo
12:47 batman i don't like having $c->$cb(...) or $c->render() all " over the place..."
12:49 ashimema oh>
12:49 ashimema you're a 'subroutine should only have one return point' person you mean
12:50 ashimema sure I read that somewhere in a best practice but I can't remember the reasoning behind it..
12:50 ashimema I should probably look it up again.. and improve my coding style
12:51 mlen108 hello fellow monks :) just a follow up to https://github.com/kraih/mojo/issues/982#issuecomment-233931161
12:52 mlen108 i'm Perl noob so I would appreciate somebody explaining me why Mojo::UA uses "more memory"
12:52 sri mlen108: Mojo::UserAgent uses keep-alive connections by default
12:52 sri so an increase in memory usage is expected
12:53 mlen108 oops didn't see that in docs
12:54 neilhwatson joined #mojo
12:55 mlen108 sri: changed to "$ua->max_connections(0);" so no connections being kept alive yet still the memory remains on very similar level
13:00 coolo joined #mojo
13:02 Kripton joined #mojo
13:06 dvinciguerra_ joined #mojo
13:23 neilhwatson joined #mojo
13:24 cpan_mojo Mojolicious-Che-0.021 by MCHE https://metacpan.org/release/MCHE/Mojolicious-Che-0.021
13:38 gizmomathboy joined #mojo
13:40 Kripton joined #mojo
14:05 Atog can i pass javascript variables to a mojo function?
14:06 Atog i want to use url_for with a js variable holding a url path
14:17 Vandal Ù_ù
14:17 Vandal JS is cliet-side, mojo is server side\
14:17 Vandal what do you mean by "pass"?
14:20 Atog i'm trying to generate a url dinamically with JS when someone clicks on a table td
14:20 Atog something like var file = $(this).text();
14:21 Atog i want to do something like <%== url_for(file) %>
14:22 Atog thing is i was using my app locally and now want to use it under a location in nginx
14:22 Atog so i have to prepend the location on every url I write
14:23 Atog i guess i'm messing things
14:25 Atog https://ssl.thorsen.pm/paste/713f9f283c27 that's what i'm playing with
14:26 Atog the critical line is $('#dir_list tr td').click(function(){ window.location.replace(encodeURIComponent($(this).text()) + '/'); });
14:28 kes joined #mojo
14:29 Vandal and whai it looks like?
14:29 Vandal in td?
14:30 Vandal Atog, I mean $(this).text()
14:30 Atog the td text is a directory
14:31 Vandal name?
14:31 Atog that way i can traverse a directory path
14:32 Vandal can you prepend location here?
14:33 Vandal like: '/location/'+ $(this).text()
14:33 Atog yeah, but i want the location part to be dynamic
14:33 Atog so i can use any location under nginx for the app
14:34 Atog not a predefined one
14:34 Vandal I would suggest to add JS var around 237
14:35 Vandal like: var prepend = <%= $location %>;
14:35 Atog yeah, i'll dig into that
14:36 Vandal and use it in JS generated url
14:36 Atog i was definitelly messing it hard trying to fit JS into mojo as you stated
14:36 Atog thanks!
14:36 Atog i
14:39 Atog the funny thing is while i wanted to play with mojo i'm mostly dealing and battling with JS now
14:41 Vandal well its web UI for you :)
14:42 Vandal I think this is why some developers invented stuff like REST API - to avoid UI :)
14:43 Atog heh :)
14:44 zivester joined #mojo
15:16 blonewolfs joined #mojo
15:27 inbioz joined #mojo
15:56 cuechan joined #mojo
16:04 jamesaxl joined #mojo
16:15 jamesaxl joined #mojo
16:17 lluad joined #mojo
16:26 jacoby joined #mojo
16:28 marty joined #mojo
16:31 marty joined #mojo
16:37 disputin joined #mojo
16:38 dod joined #mojo
16:52 jacoby joined #mojo
16:59 dvinciguerra_ joined #mojo
17:02 PopeFelix joined #mojo
17:06 mishanti1 Is it correct that there are no real breaking changes between v6.66 and v7.0?
17:08 noganex joined #mojo
17:08 dotan mishantil: the one breaking change is that the dom selection methods no longer trim whitespace
17:09 dotan it started with a bug report, and then became "how did we ever think this could work"...
17:10 Grinnz_ Mojo::URL authority method has also been removed as it's now identical to userinfo
17:10 sri and the charset plugin is gone
17:14 jacoby joined #mojo
17:14 dotan Grinnz_: can you add those to https://github.com/kraih/mojo/wiki/Upgrading ?
17:15 Grinnz_ will do in a bit
17:15 dotan Grinnz_++
17:16 jacoby joined #mojo
17:22 mishanti1 dotan , Grinnz_ : Thanks. Nothing that should affect us then. :)
17:22 mishanti1 Oh, dotan left.
17:23 mishanti1 In other news: our upgrade from perl-5.14.4+mojo-3.97 to perl-5.24.0+mojo-6.66 has gone pretty smoothly.
17:24 Grinnz_ that's a big jump (for both) :)
17:25 mishanti1 Very happy with the process, especially considering the codebase is now 26523 lines of code.
17:25 mishanti1 Plus 33395 lines of tests.
17:25 Grinnz_ always helpful
17:26 mishanti1 Indeed.
17:26 mishanti1 If we didn't have the tests this project would be absolutely unmaintainable.
17:38 disputin joined #mojo
17:45 jacoby_ joined #mojo
17:48 ashimema_ joined #mojo
18:11 dod joined #mojo
18:19 Grinnz https://github.com/kraih/mojo/wiki/Upgrading is updated
18:29 sri Grinnz++
18:31 mark joined #mojo
18:32 mike_oliver joined #mojo
18:32 mike_oliver the new mojo release broke my app again
18:33 preaction there were a couple breaking changes, yes. see https://github.com/kraih/mojo/wiki/Upgrading for a list
18:33 mike_oliver why does mojo don't follow perl's methodology ?
18:34 sri perl breaks in major releases
18:34 mike_oliver like from 4 to 5
18:34 mike_oliver my old codes from 5.8 are still working in 5.24
18:34 preaction there are plenty of minor incompatible changes in minor perl releases, like from 5.22 to 5.24
18:35 preaction Coro, for example, was broke in 5.20 and may still not work. i'm not even sure
18:36 preaction the perl core does more to ensure forwards compatibility, but they've also got orders of magnitude more dependent code to support
18:37 preaction for example, they spoke of finally breaking the empty heredoc (<<;). that will likely break code, despite the 10+ year deprecation. and there are other syntax things like this, but a lot of the breakages happen deep in the interpreter
18:38 preaction point being: perfect forwards compatibility is kind of impossible, and mojolicious's policies on this are documented. bug compatibility isn't one of the goals here, i'm pretty sure (one of the likely-affecting breaking changes in 7.0 is related to DOM whitespace truncation)
18:39 mike_oliver 10 years is fine, but broke your code each few months isn't
18:39 mike_oliver Coro does not use just "Perl", it does use the internals heavy.
18:39 mike_oliver PUSHs (CxHASARGS (cx) ? sv_2mortal (newRV_inc ((SV *)cx->blk_sub.argarray)) : &PL_sv_undef);
18:39 preaction each year, at least, which is in the mojolicious policy. also perl has a release each year
18:40 mike_oliver but Mojo doesn't broke when it changes the version digits of the release
18:41 mike_oliver it also broke from minor versions 0.x
18:41 preaction i don't think there's value in a discussion about what the perl interpreter's API really is, that's been hashed to death on p5p
18:41 preaction i know of no breakage in a minor version that weren't high-priority security-related issues
18:41 mike_oliver actually sri is a genius
18:42 mike_oliver and I do like Mojo, is easy to deploy
18:42 preaction if you're here to get help upgrading, the https://github.com/kraih/mojo/wiki/Upgrading has help. if you're here to just complain, this isn't really a good place. try a blog?
18:45 punter joined #mojo
18:59 punter Minion question: If a worker fails its job due to a runtime error, how can I capture the error message? (which in a normal perl script would go in STDERR)
19:00 punter I mean, I want to be able to see the error message after a day. How would I do that?
19:00 sri you can't
19:02 punter isn't that bad for debugging?
19:02 sri well, if you find a way let us know ;p
19:02 punter ok!
19:03 sri OMG
19:03 sri perl -E 'my @foo = (1, 2, 3); $#foo--; say for @foo'
19:03 sri so that's a thing
19:03 sri -.-
19:04 disputin joined #mojo
19:05 punter yes
19:06 punter I was also wondering whether you'd like to add the ability for minion workers to report on progress during the middle of a job execution
19:06 punter so a web user could see a progress bar
19:06 sri topic has come up a few times
19:06 punter o
19:07 punter what was the verdict?
19:07 sri think we've decided that it's easy enough for 3rd party solutions to handle that
19:07 preaction yeah, i always thought one was able to assign to $#foo. thought that was a (mis-)feature
19:08 sri punter: i mean, the feature backlog for minion is already huge https://github.com/kraih/minion/issues
19:09 sri even if we wanted to do it, it would be years away
19:09 punter ! ok
19:11 sri at this point, i think everything that can be a 3rd party module, should be a 3rd party module first
19:13 PryMar56 joined #mojo
19:17 vicash punter: bpmedley has solved the progress bar thing ... don't have a link at the moment
19:30 Grinnz_ sri: you can actually assign any number to $#foo and the array will truncate or grow accordingly
19:32 Grinnz_ not that it's really a useful thing to do :P
19:35 perlpilot It is useful when you know the max size your array should get and want to conserve a little bit of memory from Perl's standard exponential growth from growing arrays
19:35 perlpilot (at least it used to be.  I don't know for sure if it's still useful in that regard)
19:40 punter thanks vicash
20:06 orev joined #mojo
20:07 jzawodn joined #mojo
20:12 cuechan joined #mojo
20:15 punter sri, I see that the error message that a job died with (e.g. with die "this_message") is stored in $job->info->{result}. So my problem has been solved, this is what I was looking for.
20:18 sri oh, i thought you meant like segfaults
21:09 Gedge_ joined #mojo
21:31 tchaves joined #mojo
22:25 batman joined #mojo
22:53 cuechan_ joined #mojo
23:44 Vitrifur joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary