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

IRC log for #mojo, 2017-02-16

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

All times shown according to UTC.

Time Nick Message
00:09 miller I'm using Mojolicious::Lite 6.32, and I'm getting evidence that a child process is picking up another request before doing the "on finish" from the previous request.  The process instead waits for both processes to be rendered and then does the on finish for both requests together.  Is this expected behavior or a known bug or something else?
00:09 preaction do you have an example app that we can see the behavior?
00:10 miller I have the logging results.  One min.
00:11 preaction that's not going to help us reproduce it so we can see the issue, or explain why your code is doing what you're seeing
00:11 stryx` joined #mojo
00:13 good_news_everyon joined #mojo
00:13 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vDD0D
00:13 good_news_everyon mojo/master 336e2ce Sebastian Riedel: use more precise terminology when explaining delays
00:13 good_news_everyon left #mojo
00:24 PryMar56 joined #mojo
00:37 aborazmeh joined #mojo
00:37 batman joined #mojo
00:46 miller Here are the logs showing the situation: http://paste.scsys.co.uk/552390
00:46 miller @preaction I will attempt to create a minimal verification example.  However, this is a situation that was reported to me in production because the runid of a process was changing before post processing was complete, leading to locks not getting released and a lot of other badness.
00:47 preaction the runid? you mean the process id? i find that difficult to believe
00:47 miller I therefore just wanted a sanity check first, that this should not be happening, if anyone knows if a child process should block until all on-finish handlers are completed before picking up a new request.
00:47 miller no. runid=requestid.
00:47 preaction i don't know what a runid is then. is it something mojolicious provides?
00:48 miller It's just a UUID that my company's system use to identify each request.
00:48 Grinnz miller: requests can be handled simultaneously if any are async
00:48 preaction then i'm not sure how i can diagnose anything from this little information
00:49 Grinnz you should not be using global state, generally
00:49 preaction where is your runid stored? if it's not in the stash, i suspect you'll have problems
00:50 Grinnz request-specific data is best stored in the stash; worker-wide data is best stored as lexicals accessible via helper (like pg and posts here: https://metacpan.org/source/SRI/Mojo​-Pg-3.01/examples/blog/lib/Blog.pm)
00:50 miller It is localized to the process.  in global.  It's part of the implementation.  I agree that this isn't the best implementation, but it's something that was preexisting.
00:50 preaction it won't work then
00:50 preaction unless you're using a single process to run your app, which i suspect you're not
00:51 marty_ joined #mojo
00:51 miller Is it possible to configure "on finish" handlers to always complete before allowing a child to pick up a new request?
00:51 bpmedley miller : Are you saying you expect the finish event [1] to fire in the 1st request before the 2nd request is processed?   [1]: http://mojolicious.org/perl​doc/Mojo/Transaction#finish
00:51 Grinnz even in a single process, request events can occur while another request is ongoing
00:52 preaction miller: not really, no. mojolicious was designed to not do that
00:52 Grinnz always waiting for requests to complete is how you get websites that can't scale
00:52 preaction just put the runid in the stash and pass the context to all the subs that need it
00:53 Grinnz are you using any nonblocking features, such as delays or ->render_later?
00:54 miller no.  The only thing I'm using is the basic routing to convert a 10yo Soap API running on mod_perl to a Restful API running on Mojolicious.  I've utilized some "on finish" capabilities to speed up responses so that some database operations are done after the response is sent.
00:55 miller However, the on finish operations are leading ot the problems.
00:55 preaction you could turn those into Minion tasks
00:55 preaction or you could use the $c (context) for your state
00:55 miller I'm not familiar with Minion tasks.  link?
00:55 Grinnz "on finish" doesn't sound like an usual mojolicious operation, do you mean a finish event somewhere? there's probably a better way
00:56 preaction miller: http://mojolicious.org/perldoc/Minion
00:56 miller http://mojolicious.org/perld​oc/Mojolicious/Controller#on
00:56 Grinnz er. that's for websockets
00:57 Grinnz i'm surprised that would work at all if you're not using websockets
00:57 preaction all transactions have finish, it seems: http://mojolicious.org/perl​doc/Mojo/Transaction#finish
00:58 Grinnz ah, true
00:58 Grinnz still... not exactly intended to be a user facing api
00:58 miller Okay.  is there a more appropriate mechanism for doing Post Processing for a Rest API request to mojolicious?
00:58 preaction Minion
00:58 Grinnz minion is one way, but generally intended for long running tasks that are worth running in a separate worker process
00:59 Grinnz you can also just use Mojo::IOLoop->next_tick to run something, passing it the necessary info from the controller, assuming you are deploying in a way where the event loop is running
00:59 miller The types of operations I need to do in post processing are at most .5 - 2 seconds, that I want to happen immediately after render.
01:01 miller Some logging.  Some database operations.  And a db rollback in case a DB tx was left un committed.
01:01 bpmedley miller : I agree with preaction, Minion sounds perfect..
01:01 Grinnz Minion wouldn't work for operations on the same database handle, as it occurs in a separate process
01:01 preaction if it's doing a db rollback, it needs the same db connection
01:02 miller Yes, same db connection is what I need.
01:05 disputin joined #mojo
01:34 miller @Grinnz I attempted to use "hook after_dispatch" to enclose a Mojo::IOLoop->next_tick to queue some code for post processing.  However, the next_tick appears to block before sending back to response.   http://mibpaste.com/hzt4As
01:34 miller or not block, but take priority
02:23 miller I'm cautiously optimistic that I might've figured out my answer.  Setting clients => 1 (http://mojolicious.org/perldoc​/Mojo/Server/Hypnotoad#clients)
03:00 preaction it'd be a lot better to just fix it in the ways we said to fix it
03:04 stryx` joined #mojo
03:15 miller @preaction I'm all for modernizing architecture and design, but it takes a while when one still has to support existing merchants.  I've already been yelled at because this new merchant had to push their go-live date back by 2 weeks because of this bug, so the quick fix is what i need.  Even if it means my Mojo isn't configured to be bleeding edge :)
03:19 miller Thanks for all the advice.
03:35 noganex joined #mojo
03:57 jberger Grinnz there's nothing wrong with using the transaction finish event
03:57 jberger Generally
03:58 jberger Not going to fix the problem of globals though
03:58 jberger When I ported an ungainly mason app to mojo the globals were the hardest part
04:02 Grinnz for me i already had to deal with global issues when porting our CGI scripts to FastCGI
04:02 Grinnz so for mojo it wasnt so bad
04:54 prajith joined #mojo
05:04 dboehmer joined #mojo
06:11 inokenty-w joined #mojo
07:03 Vandal joined #mojo
07:35 dod joined #mojo
07:47 AndrewIsh joined #mojo
08:09 Lee is there any situation where a specific around_action hook should be called more than once?
08:15 trone joined #mojo
08:24 rshadow joined #mojo
08:25 Lee https://github.com/leejo/mojo/commit/de​084400c96a6d6543d66d7692e339f1d93de280 # well i'm not sure if this helps explain the issue i'm seeing
08:33 blumbi joined #mojo
08:44 VVelox_ joined #mojo
09:26 sugar joined #mojo
09:35 dod joined #mojo
09:41 foursixnine joined #mojo
09:58 batman joined #mojo
09:58 sugar joined #mojo
10:02 batman Lee: maybe if you have an "under" ?
10:05 Lee batman: we do
10:10 dod joined #mojo
10:16 howitdo joined #mojo
10:18 batman Lee: I guess the "under" is also an action, so that will the trigger around twice...
10:19 batman *then
10:24 Lee is there any other action that could cause it to fire twice?
10:25 cpan_mojo Mojo-IOLoop-HoboProcess-0.003 by MARIOROY https://metacpan.org/release/MARIO​ROY/Mojo-IOLoop-HoboProcess-0.003
10:36 sugar joined #mojo
10:52 tchaves joined #mojo
10:55 tchaves joined #mojo
11:13 sugar joined #mojo
11:42 marcus joined #mojo
11:54 disputin joined #mojo
12:35 marty joined #mojo
12:57 rshadow joined #mojo
13:01 sugar joined #mojo
13:04 dod joined #mojo
13:10 dod joined #mojo
13:11 sri Lee: i don't like the link in your doc patch, think it would be nicer if it just said "nested routes"
13:12 Lee sri: fixed
13:21 aborazmeh joined #mojo
14:05 mat does mojolicious has an argument parsing similar to rails where you can have an input named foo[1][bar] and it creates arrays and hashes
14:10 sri not built in
14:11 sri there were plugins
14:11 blumbi joined #mojo
14:11 gizmomathboy joined #mojo
14:14 foursixnine joined #mojo
14:21 VVelox joined #mojo
14:25 blonewolfs joined #mojo
14:32 msestak joined #mojo
14:47 sugar joined #mojo
15:13 dod joined #mojo
15:24 kes joined #mojo
15:26 kes Where I can read about M:R:Pattern? about why we need it and what is does.
15:27 dhg joined #mojo
15:27 kes http://mojolicious.org/perldo​c/Mojolicious/Routes/Pattern Here too few description
15:46 sh14 joined #mojo
15:56 stryx` joined #mojo
16:03 sugar joined #mojo
16:09 irqq joined #mojo
16:16 bwf joined #mojo
16:16 lluad joined #mojo
16:22 jberger joined #mojo
16:22 sri somethign to think about https://github.com/kraih/mojo/issues/1058
16:22 sri maybe even volunteer for
16:23 jabberwok agree. -- a short "cheat sheet" would be a good start
16:24 mrEriksson To be honest, I didn't find the transition all that complicated, the existing docs where quite good on the subject.
16:25 mrEriksson And I'm both a perl and web newbie
16:25 sri it's definitely a very common problem that comes up a lot here
16:26 jberger so is that going to be a TL;DR section in Growing?
16:27 mrEriksson Oh,, Maybe I just got lucky and ended up in a good place in the docs when doing so then :)
16:27 sri jberger: no, cheatsheet in Mojolicious::Lite
16:29 jberger ala the "longer version" stuff in other documentation
16:30 jberger interestingly, I've actually started to use Full-ish syntax even in Lite
16:30 jberger unless it really is only going to be a demo
16:30 jabberwok it should be a short section; Lite.pm only defines a few monkey_patched subs on 'routes' (get, put, any...), on 'app' (helper, hook, plugin) and a few odd bits.
16:31 jberger but it makes transitioning a PoC into a real thing by using more full syntaxes
16:31 * sri updates https://github.com/kraih/mojo/issues/1058
16:36 jabberwok as a Perl monger since 1995, i know the first thing that tripped me up when approaching the Tutorial was: >>app->start;<< -- hey, wait, is 'app' a function, or some dark magicks? -- if we could explain in the Lite-to-Full section at least "see also: monkey patching", that would go a long way to putting folks (like me) at ease
16:37 sugar joined #mojo
16:37 sri jabberwok: write down a recipe, add it to the issue as a comment
16:37 jberger see this is where the whole thing comes off the rails for me actually
16:37 sri jberger: let him write it down
16:37 jberger because once you start explaining all that you basically end up at the Growing guide, don't you?
16:37 jberger k
16:38 jabberwok ok
16:38 sri here's the thing, he won't get to explain
16:38 sri it's a cheatsheet, all he has is example code
16:38 sri if he makes a mess, it's out
16:53 jabberwok http://www.pastebeest.com/F9  perhaps
16:56 jabberwok http://www.pastebeest.com/FB    also hook and helper.  I think that should do it.
17:26 stryx` joined #mojo
17:36 Pyritic joined #mojo
17:49 dod joined #mojo
17:55 sugar joined #mojo
18:11 PryMar56 joined #mojo
18:36 rshadow joined #mojo
18:50 dod joined #mojo
18:50 disputin joined #mojo
19:00 ashimema joined #mojo
19:17 * sri has a feature request for SQL::Abstract
19:17 sri ->update() doesn't do returning
19:17 sri $sql->update('foo', {bar => 'baz'}, {id => 123}, {returning => '*'})
19:18 * Grinnz didn't even know that was a thing in postgres
19:19 sri it is, quite nice, returns all rows that were updated
19:22 coolo I guess that's the downside of abstractness - it can only do so much specifics :)
19:23 sri umm, someone already added it :O https://github.com/dbsrgits/sql-abstract/com​mit/95904db55eaadc9804f188c1f8a157bf916487d9
19:23 coolo sri: but I just learned - hackweek only starts tuesday. So I've got you one more day to fix things ;)
19:23 sri but it wasn't documented
19:23 * sri shoos coolo
19:23 Grinnz sri: theres been no SQL::Abstract release since a couple months before that commit
19:24 preaction might be waiting for the DBIC governance thing to calm down so we know who can send out new releases...
19:25 * sri is getting a bit disappointed
19:25 sri so yea, i'm in the market for an SQL::Abstract fork, if someone steps up
19:26 pink_mist I thought that was already decided
19:27 coolo SQL::Unreal!
19:27 sri honestly, judging by this DBIx::Class maintenance must have been a mess for the last few years
19:27 preaction there's not been a release despite a few new features waiting on master, so i don't know if it's been decided
19:32 Peppard joined #mojo
19:35 sri or i make my own SQL generator
19:36 sri last minute hackweek project ;p
19:42 sugar joined #mojo
19:49 disputin joined #mojo
19:53 genio sri: Maybe a bit of poking certain people could get that  update documented and released?
19:54 genio ah, it is documented in that commit.
19:55 sri yea, i thought it was released and undocumented at first
19:56 sri didn't even cross my mind that something could just lie on github unreleased for years
19:56 genio https://github.com/dbsrgits/sql-​abstract/compare/v1.81...master
19:57 genio There's a bit of changes there, but it shouldn't take someone too long to review and maybe cut a dev release (massive assumptions here).
20:04 marty_ joined #mojo
20:04 orev joined #mojo
20:07 polettix joined #mojo
20:07 dod joined #mojo
20:08 irqq joined #mojo
20:27 disputin joined #mojo
20:48 PopeFelix joined #mojo
20:48 PopeFelix How would I go about testing a Mojolicious Command?
20:49 PopeFelix My app uses a queue, and we spawn workers to consume that queue via a "worker" command. I've made a change to the command class, and I'd like to develop a unit test that shows the change works.
20:49 Grinnz when in doubt steal from mojo's tests :P https://github.com/kraih/mojo/blo​b/master/t/mojolicious/commands.t
20:49 PopeFelix But I don't have the first idea as to how.
20:50 PopeFelix But stealing is wrong! ;)
20:50 PopeFelix Seriously, though, thanks, Grinnz - I'll look at that. :)
21:05 polettix joined #mojo
21:18 user_7223 joined #mojo
21:20 user_7223 I have a question
21:20 user_7223 How can I only access the numbers in a json array?
21:20 user_7223 https://nopaste.linux-dev.org/?1120980
21:20 user_7223 Not the string -  I could use looks_like_number, but is there a better way?
21:21 user_7223 I tried ->[1], but it did not work
21:22 howitdo joined #mojo
21:22 preaction foreach my $item ( grep { looks_like_number } @$face ) { ... }
21:26 user_7223 Ok, thanks. there is no other way through an element such as ->[0]?
21:27 preaction you can do that, sure, but how do you know if it's a number before you grab it?
21:31 user_7223 true, but
21:31 user_7223 your solution will work, but what happens if the text string is a number too?
21:31 user_7223 It will mess up the result
21:31 user_7223 Some streets in Germany are just plain numbers
21:32 user_7223 thus, accessing it by ->[0] or ->[1] would be much more safe, but I can't find a way to do it
21:32 perlpilot user_7223: Are those items guaranteed to come in pairs?
21:32 user_7223 Yes
21:34 Grinnz my %by_street = @$facet; my @numbers = values %by_street;
21:34 perlpilot user_7223: then you just want the odd numbered ones?
21:34 Grinnz (wouldn't work if there's duplicates of the first values)
21:34 perlpilot Grinnz: I'm not sure uniqueness is guaranteed  ... yeah
21:35 Grinnz otherwise, my @pairs = pairs @$facet; my @numbers = map { $_->[1] } @pairs;
21:35 Grinnz List::Util 'pairs'
21:36 Grinnz or skip the middleman, my @numbers = pairvalues @$facet;
21:37 user_7223 thanks for the help. I just saw it can also be printed as xml <int name="hauptstr. 27">2</int>
21:37 user_7223 This would be easier, right?
21:37 Grinnz not really
21:38 Grinnz xml is infinite complication
21:41 user_7223 true
21:41 user_7223 i will go with  foreach my $item ( grep { looks_like_number } @$face ) { ... }
21:41 Grinnz i wouldn't recommend that
21:41 Grinnz looks_like_number is usually not a good idea to rely on
21:42 Grinnz the positions are the reliable aspect here, from what you've said
21:42 user_7223 yeah
21:42 perlpilot user_7223: I'd use one of Grinnz's suggestions.
21:43 Grinnz also, you might want to try a more general perl help channel for questions like this, this is for more mojolicious specific help
21:43 Grinnz like #perl or #perl-help here, or #perl on freenode
21:43 user_7223 I know, but I think it's already solved now
21:43 user_7223 i will go with the pairvalues solution
21:44 user_7223 I hope they come always in pairs (at least they did so far)
22:08 sugar joined #mojo
22:16 polettix joined #mojo
22:55 dave joined #mojo
23:22 sugar joined #mojo
23:28 gabriel joined #mojo
23:36 zach this is sort of a perl sort of mojo question, but I'm not sure what I'm doing wrong
23:36 zach I have a mojolicious app with the default t directory for tests, but when I run prove it says it can't find my app in INC and fails the default test
23:36 preaction prove -l
23:36 purl well, prove -l is my friend.
23:38 sri aww
23:42 polettix joined #mojo
23:57 batman joined #mojo

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