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

IRC log for #mojo, 2016-05-13

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

All times shown according to UTC.

Time Nick Message
00:15 ZoffixWin joined #mojo
00:20 ZoffixWin I'm not following why this gives me 'Premature connection close', yet the blocking version works: https://github.com/zoffixznet/perl6.party/blob/master/app.pl#L38
00:21 bpmedley ZoffixWin: How many seconds elapse?
00:21 ZoffixWin My guess would be the UA goes out of scope and that's why, but what's a good way to fix it? Should I just declare the UA at the start of the app and call it that way?
00:21 ZoffixWin bpmedley, zero?
00:21 ZoffixWin [Thu May 12 20:14:58 2016] [debug] 200 OK (0.002391s, 418.235/s)
00:22 bpmedley I'm not sure if this is still good practice; however, what I've done is store the $ua in the controller's stash.
00:22 ZoffixWin Seems this is answer-your-own-question-when-you-ask-on-IRC case.
00:22 bpmedley ZoffixWin: What do you mean?
00:22 ZoffixWin Indeed, the issue is the UA goes out of scope and gets destroyed.
00:23 bpmedley And, you're saying you don't wanna store the $ua in the stash?
00:23 ZoffixWin bpmedley, I don't see a reason to store my UA in the controller. I've just done this: https://github.com/zoffixznet/perl6.party/blob/master/app.pl#L12
00:24 bpmedley I don't know the pros/cons for each methodology..
00:25 ZoffixWin It's a tiny app anyway :)
00:26 ZoffixWin Ah, I guess I did ask for the best way, sorry :)
00:26 * ZoffixWin is drunk
00:30 ZoffixWin left #mojo
00:43 * nicomen avoids mentioning he has had two beers
00:45 Adurah joined #mojo
01:01 jberger ZoffixWin: you need to keep a strong reference to the original request transaction
01:01 jberger my $tx = $c->tx
01:51 good_news_everyon joined #mojo
01:51 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vrYm3
01:51 good_news_everyon mojo/master 2f15e46 Sebastian Riedel: use getcwd consistently
01:51 good_news_everyon left #mojo
02:04 good_news_everyon joined #mojo
02:04 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vrYmh
02:04 good_news_everyon mojo/master 4ae568a Sebastian Riedel: formalize home detection strategy
02:04 good_news_everyon left #mojo
02:08 noganex joined #mojo
02:50 ivi joined #mojo
03:18 Guest-quest joined #mojo
03:41 damaya joined #mojo
03:53 damaya Is there any advantage Mojolicious::Plugin::ForkCall vs non-blocking?
04:06 mattp damaya: they are fundamentally opposing things
04:06 mattp if you can complete your operation non blocking you dont need forkcall
04:33 damaya Ah ha, ok. I'm connecting to an email server via Net::SMTP, 20 emails at a time. So, trying to do all 20 asynchronously.
04:33 damaya And then render the results from that.
04:34 coolo for tasks like that minions were made
04:35 coolo or do you want to render the SMTP reply ?
04:35 damaya Ah, render it :)
04:42 damaya Really I'm just translating a nodejs app to Mojolicious. The nodejs app uses Promises, trying to figure out what's similar in Mojolicious land.
04:44 jberger damaya: sending mail is a good task for a job queue
05:12 n16gel joined #mojo
05:24 damaya jberger: I realize that, but unfortunately this is a worker in itself... it doesn't have to respond quickly, I just need it to render something, but I'd like to do the calls for @email async'd.
05:30 damaya jberger, I have a question regarding your article, "Writing non-blocking applications with Mojolicious Part 2".
05:30 damaya On this line, my @titles = map { $_->res->dom->at('title')->text } @_;
05:31 damaya In the example using Mojo::IOLoop::Delay, how does that map the title from all URLs? Does $_->res->dom contain the dom from all the requests combined or something?
05:52 bpmedley damaya: Are you using Minion?
05:55 stigo joined #mojo
05:55 dod joined #mojo
06:00 jasanj joined #mojo
06:01 dod joined #mojo
06:03 jasanj hello, Mojo::IOLoop will stop automaticlly if their were no more watcher, my case is, the ioloop hanged and I do not think there is any watcher still exist, is thers a way to find out the which watcher the ioloop is waiting for ?
06:04 henq joined #mojo
06:04 bpmedley jasanj: http://mojolicious.org/perldoc/Mojo/IOLoop#DEBUGGING <-- This may help
06:04 bpmedley Also, MOJO_EVENTEMITTER_DEBUG
06:12 jasanj bpmedley: just tried this, the debug information is not i want
06:12 McA joined #mojo
06:44 jasanj i have print $ioloop->reactor->{io} and $ioloop->reactor->{timers}, both empty {}
06:45 AndrewIsh joined #mojo
06:55 damaya joined #mojo
06:55 damaya It's actually a Java application that creates a job using AWS SQS, which then posts to this API (The Mojolicious one) and waits about a minute for a response.
06:56 damaya The Mojolicious app basically loops over 20 emails, creating a socket connection to the SMTP server and does not send an email, just checks response from SMTP server for a RCPT TO then quits.
06:56 damaya The problem is, the connections happen one by one rather than forking 20 socket connections. I'm using an IOLoop for this, but yeah.
06:57 damaya :D
07:09 punter joined #mojo
07:20 Vandal joined #mojo
07:22 ladnaV joined #mojo
07:28 trone joined #mojo
08:25 icjs joined #mojo
08:27 osfabibisi joined #mojo
08:54 vytas joined #mojo
09:24 meshl joined #mojo
09:40 jasanj batman: found my previous issue was came from Mojo::IOLoop::ReadWriteFork
09:41 jasanj RWF will not delete the watcher to make ioloop stop automatically?
09:41 jasanj after the $fork->run; finished
09:43 jasanj or is ther any way to delete the watcher of RWF, and I do not manually stop the ioloop
09:51 jasanj batman: i tried delete $fork->{ev_child} in my on 'close' event to solve, seems it can be a workaround
09:51 jasanj form e
09:51 jasanj for me
10:23 n16gel joined #mojo
10:26 batman jasanj: don't my a PR which adds stop() or some other fancy solution which removes the watcher when all children are taken care of
10:26 batman Need a test though...
10:26 batman My = mind
10:27 batman Never had a reason for automatically stopping the IOLoop.
10:28 batman I don't have enough TUITS to fix it myself now.
10:55 dvinciguerra joined #mojo
10:59 n16gel joined #mojo
11:06 tchaves joined #mojo
11:19 kaare joined #mojo
11:54 Dandre left #mojo
11:54 jberger damaya: @_ is all the transactions
11:57 jberger damaya: is there a nonblocking smtp client m
11:58 jberger s/m/?/
12:05 mdom There's even https://metacpan.org/pod/Mojo::SMTP::Client ... :)
12:09 jberger mdom++
12:10 mdom I haven't used it though, so no idea how good it is
12:11 inokenty joined #mojo
12:46 ksmadsen joined #mojo
12:47 gizmomathboy joined #mojo
13:00 ramortegui joined #mojo
13:21 n16gel joined #mojo
14:03 Kripton joined #mojo
14:04 icjs joined #mojo
14:21 zivester joined #mojo
14:27 PopeFelix bpmedley, thank you. I'll play with this shortly. :)
14:31 icjs joined #mojo
14:36 mishanti1 Does anyone know if there are anyone putting effort into building an ORM on top of Mojo::Pg with all it's non-blocky goodness?
14:36 mishanti1 I've seen Mojo::Pg::ORM, but wondering about others as well, if there are any.
14:38 jberger I think batman's Mad::Mapper was on that order
14:38 jberger but tbh I haven't done anything with it myself (sorry batman)
14:40 mishanti1 Mad::Mapper seems clean. :) Wonder how much effort it needs to support some of the relational-features that eg. DBIx::Class has.
14:40 punter joined #mojo
14:41 mishanti1 jberger: Thanks for the input. Did not know of Mad::Mapped before you mentioined it.
14:41 mishanti1 s/before/until/
14:43 jberger mishanti1: there have been long running whispers of non-blocking in DBIC
14:44 jberger but they so far remain whisper and rumor
14:51 ribasushi o.O
14:51 ribasushi jberger: not sure what you are referring to...
14:52 jberger just the long discussions of how nonblocking dbic would work, which never seem to go anywhere
14:53 jberger the guys in Milwaukee.pm basically have it btw
14:53 * jberger wonders if he can find that gist
14:53 ribasushi https://gist.github.com/ribasushi/032fbb8b58e2b0d62fae <---- that's all the discussion I am personally aware of
14:54 ribasushi never heard of milwaukee.pm's work (not saying it's good/bad - saying I have no idea)
14:55 jberger so if you just understand that this is poking at internals but only to demonstrate an idea ...
14:56 ribasushi mishanti1: my 2c (from my pov): async-for-the-sake-of-async makes as much sense as java's "threads because threads!" model. In the case of a RDBMS layer this is additionally complicated by "what do you do with transactions (on both logical and procedural level)?"
14:56 jberger use this as the injection point: https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082821/lib/DBIx/Class/ResultSet.pm#L1288
14:56 jberger where you can use as_query to get the sql, run the sql and then do: https://github.com/mcsnolte/Mojo-Pg-DBIC/blob/master/t/mojopgdbic.t#L78
14:57 ribasushi mishanti1: so far no clear "this is how async should work when confronted with the usual write/read/write/(commit|rollback) cycle" has emerged
14:57 jberger (you can see the as_query several lines up)
14:57 ribasushi mishanti1: when someone cracks this conceptual deadlock - there will be multiple implementations of it, I am sure
15:04 jberger ribasushi: thoughts?
15:04 ribasushi jberger: on...?
15:04 jberger the code I linked
15:04 ribasushi sorry missed that, looking
15:04 jberger that's basically the synopsis of what milwaukee.pm is trying
15:06 ribasushi jberger: this seems to be extra work to achieve the same thing as what I described on this line: https://gist.github.com/ribasushi/032fbb8b58e2b0d62fae#file-gistfile1-txt-L476
15:07 ribasushi jberger: essentially it is the same stuff, I just outlined hook points higher up
15:08 ribasushi jberger: and again - it does not address at all what to do with transaction-involving business logic
15:08 jberger DBIC would no longer care
15:08 jberger that's up to the code running the queries
15:09 jberger and yes it is basically what we discuss at the end of that chat, but someone actually sat down to try it (and not prompted by me either, they just showed me when I did a guest talk there)
15:11 tchaves joined #mojo
15:17 ribasushi https://github.com/mcsnolte/Mojo-Pg-DBIC/commit/4f9d48cf52e6aecd782f1e2e20e1e1ae07a795a3#commitcomment-17468260
15:17 ribasushi jberger: ^^ closing the information loop
15:20 jberger ribasushi: cool
15:29 cosimo joined #mojo
15:29 cosimo joined #mojo
15:56 PopeFelix bpmedley, that won't work for me, I think. But thanks just the same.
15:57 PryMar56 joined #mojo
16:01 abra joined #mojo
16:06 icjs hiall, can someone give me a correct example of setting a filename attachment in content-disposition via Mojo::Headers?
16:07 icjs i'm doing:   $self->res->headers->content_disposition( 'attachment; filename=' . $filename ) - but not seeing the Content-disposition header when i hit my route via Postman
16:13 jberger icjs: I think we'd have to see more code
16:16 punter joined #mojo
16:22 icjs jberger, hmm ok. but the guts of it are pretty much the above followed by: $self->render( data => $foo->{ stuff } )
16:22 PopeFelix My app uses a queue to do some of its work. I start the queue workers with a Mojo command, 'start_workers <queue name>'. How can I execute that command from inside my unit test?
16:23 icjs jberger, if i Dumper  $self->res->headers i can see the headers set correctly
16:23 jberger icjs: what about watching the request with MOJO_DAEMON_DEBUG=1
16:23 icjs jberger, thanksm will try that
16:24 jberger PopeFelix: you can use $minion->perform_jobs or else you could instantiate your command and call run
16:26 icjs jberger, using that debug evavar i can see the headers set correctly
16:26 icjs must be postman being strange
16:26 jberger right
16:27 PopeFelix jberger, I'm not using minion, but Command::run should work. thanks.
16:27 jberger PopeFelix: in that case presumably your command is a thin wrapper on some other function, just call that
16:28 PopeFelix jberger, yeah, that's what I was thinking.
16:30 kaare joined #mojo
16:31 dod joined #mojo
16:38 dod1 joined #mojo
17:02 genio Well, the more I research, the more I think Exception::Class and Throwable cover the use cases well.  :/  I'm seeing less and less of a need for Exception other than to provide documentation and usage examples maybe
17:04 jberger genio: maybe give it to core and talk Exception::Class and Throwable into subclassing from it (as a nearly empty class)
17:05 jberger or maybe use it as an abstraction layer or utility module to help smooth over difference?
17:05 abra_ joined #mojo
17:05 phillipadsmith joined #mojo
17:06 genio I think giving it to core sounds like the best idea to me.
17:06 jberger eval { ... }; if (my $e = Exception->new($@)) { ... # do somthing with a standard interface }
17:07 jberger yeah perhaps
17:07 genio hrm.  That sounds like the beginnings of edge case finding like nobody's business.
17:08 jberger it would be entirely about finding edge cases :-P
17:08 genio although possibly not a bad idea.
17:08 harleypig joined #mojo
17:08 jberger I like the idea of upgrading a string exception to an object though
17:09 jberger I don't know if there is any prior art for something like AnyException or Exception::Any or something
17:09 jberger I'd at least talk with #toolchain or #p5p and see what would be most useful
17:11 genio I'll see about writing up ideas in that direction this weekend. If I come to the "oh, this is horrible" conclusion, I'll give it to someone else
17:11 genio jberger++
17:27 damaya joined #mojo
17:30 damaya So, this is roughly what I have: http://paste.scsys.co.uk/paste
17:31 damaya The fork_call does in fact fork, but the code continues on before all children return. Any way to make it wait for all children to die before returning from helper?
17:31 jberger damaya: a meta joke? you've got nothing? :-P
17:31 damaya haha
17:32 damaya I could post the entire code, was just posting what was relevant.
17:32 jberger damaya: your link doesn't point to your code
17:33 jberger it points to the main paste page
17:34 damaya http://paste.scsys.co.uk/513680
17:34 damaya lol, thanks jberger :D
17:35 damaya that's the entirety of the code, but the validate_email helper is where I'm having issues...
17:35 dod joined #mojo
17:36 jberger you need Mojo::IOLoop::Delay
17:45 damaya Ah ha! I knew it. That's all I need to know jberger, I will try to figure it out from here.
17:46 damaya I had messed with M::IOL::D, but didn't figure it out. Just good to know that I was on the right track.
17:48 jberger also you pass $delay->begin to validate_email but you don't have a callback slot there
18:07 kaare joined #mojo
18:07 trwww joined #mojo
18:15 dvinciguerra joined #mojo
19:43 gtodd can I use the dumper helper to dump any old data structure onto a page ?    ... do they have to be stashed or can I just write my $hash = ( what > 'huh?' } ;  ....  @@dump.html.ep  <%= dumper $hash %>  ...
19:44 jberger I mean it would be $hash = { what => 'huh?' }; but yes
19:44 gtodd oops yeah sorry typo
19:45 punter joined #mojo
19:48 gtodd I have  of perl scripts that grab system command output and stuff it in hashes ... thought it might be fun to turn them into "mojo scripts" ...
19:48 jberger figured, but I didn't want to just say "yeah that's ok"
19:50 gtodd s/have of/have a bunch of/ s/in hashes/into hashes/   ... thanks and have a good weekend :)
19:54 meshl joined #mojo
20:12 meshl joined #mojo
20:24 odc joined #mojo
20:41 mishanti1 ribasushi , jberger : thanks both of you for the links. Definitly interesting.
20:41 mishanti1 And I agree 'async-for-the-sake-of-async' makes no sense, but 'async-for-the-sake-of-high-qps-non-blocking-web-apis' makes a lot of sense to me.
20:41 mishanti1 But then again, I just might be bonkers.
20:41 jberger mishanti1: a thing to note
20:42 jberger Mojo::Pg is still synchronous for transport due to a limitation in DBI or DBD::Pg (I forget which)
20:42 jberger the async you get is for a long running query
20:42 jberger while the db is actually preparing the results
20:42 mishanti1 jberger: Which to me is very useful, at least for some of the conde I maintain.
20:42 jberger ok, just as long as you know that
20:42 mishanti1 s/conde/code/
20:43 jberger for many people doing CRUD it wouldn't be worth it
20:43 mishanti1 jberger: Well I did not know it, so thanks for pointing it out. However the workload here is such that _any_ async capabilities makes a great deal of difference.
20:44 * mishanti1 goes afk for a while. Food going in.
20:48 dvinciguerra joined #mojo
21:51 dvinciguerra joined #mojo
21:56 osfabibisi joined #mojo
22:07 disputin joined #mojo
22:09 dvinciguerra joined #mojo
22:11 disputin joined #mojo
22:15 disputin joined #mojo
22:21 disputin joined #mojo
22:38 trwww joined #mojo
23:41 dvinciguerra joined #mojo
23:55 disputin joined #mojo

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