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

IRC log for #mojo, 2016-03-22

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

All times shown according to UTC.

Time Nick Message
00:02 Rubes joined #mojo
00:02 sri looks like postgres 9.6 will be pretty cool http://rhaas.blogspot.de/2016/03/parallel-query-is-getting-better-and.html
00:40 Rubes joined #mojo
01:12 aborazmeh joined #mojo
01:58 asarch joined #mojo
02:26 Rubes joined #mojo
02:40 mcsnolte joined #mojo
03:25 kaare joined #mojo
03:34 noganex joined #mojo
03:51 Rubes joined #mojo
03:56 jberger now with even more memes :-P http://jberger.github.io/MojoliciousIntroduction/#/
03:58 sri jberger: on slide 4 you could mention the toolkit thing instead of duct tape :)
03:59 jberger oh right I forgot we changed that language
04:05 jberger updated
04:07 mroy joined #mojo
04:08 mroy Thank you bpmedley and jberger. Updated Mojo::IOLoop::HoboCall https://gist.github.com/marioroy/9ee06ce95ce62f88d79d
04:10 mroy The controller and Hobo worker may utilized MCE::Shared.
04:13 mroy After some thought have decided to have HoboCall compatible with ForkCall to *not* introduce another API. This is a little gift for Mojolicious. It works on all the major platforms including Cygwin, Windows, FreeBSD, OpenBSD, Linux, Solaris, etc.
04:14 jberger mroy: very cool
04:16 mroy Am liking Mojolicious and want to use HoboCall in order to benefit from MCE::Shared capabilities; e.g. MCE::Shared->queue, MCE::Shared->Ordhash, etc.
04:16 jberger does it have to poll?
04:16 jberger does hobo have any event emitting system?
04:17 mroy MCE::Hobo does not at the moment. But, Mojo::IOLoop::HoboCall may
04:17 mroy Please forgive me if I misunderstand. Mojolicious is still new to me.
04:18 jberger the fact that you have to use a recurring timer to check if the hobo instance is_running
04:18 jberger if hobo gave you some finish event you could listen to it would be easier
04:18 mroy The is_running in MCE::Hobo is very fast or in other words does so with little overhead.
04:19 sri the poll interval adds latency
04:20 sri so, polling is generally avoided at all costs
04:20 mroy is_running can be called 900,000 per second on a Mac.  Over 1 million per second under Linux. So, the poll in Mojo::IOLoop::HoboCall at 0.05 is where the polling occurs.
04:22 mroy ok, will think about it and look deeper at emitting events in MCE::Hobo
04:24 mroy MCE::Hobo can take options. Therefore, can specify running from Mojolicious and emit events and do away with polling. Thank you. Will try.
04:25 sri that's the other bad extreme
04:25 sri a very small interval means that the event loop wakes up all the time and will never be idle
04:26 sri polling is really never good, avoid it if you can
04:26 sri the perfect case would be you waiting for something to happen on a socket
04:26 mroy Mojo::IOLoop::HoboCall was based on Mojo::IOLoop::ProcBackground initially and that does polling.
04:27 sri and once the socket is active you trigger events and stuff to do whatever you need
04:27 sri nobody said ProcBackground was good ;p
04:27 mroy I can do the socket thingy.
04:28 sri that gets you ideal resource usage
04:29 sri if you can you always want the event loop to wait for io
04:30 sri http://mojolicious.org/perldoc/Mojo/IOLoop#reactor
04:30 mroy Ok. Will try some things. But will have to deal with the Windows platform. Will make it work.
04:30 sri like that readable/writable check
04:31 sri s/check/watcher/
04:32 mroy Nice. I can pass the reactor instance to MCE::Hobo->create( { reactor => $r, posix_exit => 1 }, \&code, @args ) to trigger events.
04:34 mroy thank you. will try the reactor. Am not sure if the reactor socket hangs on Windows during forking new workers or during workers exiting. Will try stuff.
04:38 inokenty-w joined #mojo
04:38 mroy Ok, got it. Will make a handle and pass the handle to MCE::Hobo, not the reactor instance. Mojo::IOLoop::HoboCall will monitor the handle via the reactor.
04:51 good_news_everyon joined #mojo
04:51 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/va9BU
04:51 good_news_everyon mojo/master cb9eaf6 Sebastian Riedel: a few more links
04:51 good_news_everyon left #mojo
05:00 Rubes joined #mojo
05:08 Rubes joined #mojo
05:15 irqq joined #mojo
05:49 melo joined #mojo
06:00 melo joined #mojo
06:00 melo1 joined #mojo
06:06 Rubes joined #mojo
06:08 Grinnz joined #mojo
06:36 mroy joined #mojo
06:36 dod joined #mojo
06:37 irqq joined #mojo
06:38 mroy sri: jberger: I tried the reactor suggestion by sri. It is working across the board and requires MCE::Hobo 1.704 which accepts *channel* as an option. https://gist.github.com/marioroy/348e4d098bc7967598fa
06:38 dod joined #mojo
06:50 mroy For the time being, the Hobo worker writes "done\n" when finished. The IO for the actual data is handled by the shared-manager process. Same as before.
06:55 melo joined #mojo
06:55 kes joined #mojo
07:01 mroy joined #mojo
07:04 mroy met to say the update requires MCE::Hobo 1.002.
07:06 dod joined #mojo
07:11 dod joined #mojo
07:30 Rubes joined #mojo
07:30 salva joined #mojo
07:54 Vandal joined #mojo
07:59 ichi joined #mojo
08:12 osfabibisi joined #mojo
08:24 AndrewIsh joined #mojo
08:34 trone joined #mojo
08:35 cpan_mojo Mojo-SNMP-0.12 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojo-SNMP-0.12
08:40 trone joined #mojo
09:14 CHYC joined #mojo
09:17 CHYC joined #mojo
09:57 Rubes joined #mojo
10:45 Kripton joined #mojo
10:49 coolo joined #mojo
11:02 cpan_mojo Mojo-IRC-0.30 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojo-IRC-0.30
11:02 batman any Mojo::IRC users here? you might be interested in the change in 0.30 ^^^ (no more generic irc_error event)
11:03 batman https://github.com/jhthorsen/mojo-irc/commit/666053b54b02fae7f650f8a003a6c65e1ff5fcf2 <-- details
11:04 nic my $work irc has been shut down, and I'm fed up with hipshit killing devices, so I'm on the lookout for something lightweight (ideally based on Mojolicious)
11:09 nic [batman has just persuaded me to look again at installing irc (and wait for the new convos frontend)]
11:09 batman you don't really have to wait. just clone and run convos (don't install convos)
11:10 * nic taps foot
11:10 nic batman: I'm WAAAITING!
11:10 batman ;)
11:11 batman i'm also waiting
11:12 vytas joined #mojo
11:17 dvinciguerra joined #mojo
11:19 melo joined #mojo
11:22 Kripton I am trying to do some attribute checks using Mojo as base class.
11:22 kivilahtio joined #mojo
11:22 Kripton There is a way do to something like this ?
11:22 Kripton http://pastebin.com/ujW5DxMT
11:24 nic Kripton: Don't you want to use Moo?
11:25 crux joined #mojo
11:26 Kripton Moo would be my last last option
11:27 nic I haven't used it yet, but that's what I'm going to reach for the day I want to do what you're describing
11:27 bpmedley Kripton : I think callbacks are there for default values.
11:28 nic bpmedley: think of it as pseudo-code.  The clue was "like"
11:28 bpmedley Sure, and I'm just saying that callbacks are called once.  Is that correct?
11:28 nic Once-per-need
11:29 Kripton I personally think that moo is too heavy, based on my trials ..
11:29 nic You can reset the attribute by deleting the underlying hash key
11:30 nic once-per-need-per-object  -- Mojar::Class::Share does similar for once-per-need-per-class
11:33 nic Anyone got a sysadmin friend?  They might find Mojar::OpSys::Ps useful for OS process monitoring
11:34 batman Kripton: you could use https://metacpan.org/pod/Class::Method::Modifiers
11:34 batman before my_attr => sub { croak ('Invalid name size') if $_[1] and 10 < length $_[1] };
11:35 batman s/my_attr/name/
11:35 nic ($work use it hooked to zabbix, but it works with nagios, checkmk, etc.)
11:44 Kripton batman: Thanks. looks promising :)
11:44 batman you're welcome
11:58 kivilahtio joined #mojo
12:01 Kripton batman: It worked like a charm, Thank You again
12:01 batman :)
12:14 binlei joined #mojo
12:15 binlei left #mojo
12:51 zivester joined #mojo
12:57 Kripton_ joined #mojo
13:22 dvinciguerra_ joined #mojo
13:43 jb360 joined #mojo
13:51 * Grinnz boggles at "moo is too heavy"
13:51 Grinnz batman, interesting, what led to this change?
13:52 batman Grinnz: which change?
13:52 Grinnz in Mojo::IRC
13:52 batman Grinnz: there's actually a "irc_error" event, so you need  way to cancel out "irc_error" events already handled
13:53 plicease joined #mojo
13:53 batman so if you *had* $irc->on(err_nicknameinuse => ...) and $irc->on(irc_error => ...) then both will be called right?
13:53 pink_mist Kripton: did you mistake Moo and Moose? Moose is the heavy one. Moo isn't heavy at all
13:54 Grinnz right...
13:55 batman so it's more explicit now. but if you *really* want a catch all event, you can use "irc_any" event and filter on $msg->{event}
13:55 Grinnz well i don't use irc_error, but irc_any is sort of like what i wanted before :)
13:56 batman Grinnz: yeah... that came back to me, so instead of just dropping irc_error i added irc_any :)
13:57 batman i mostly added the event because i wanted to say "hey! now you got this" instead of saying "you're screwed"
13:58 batman uhm... is that bad language..? (please correct me if so)
13:58 Grinnz not really
13:59 batman :)
14:00 asarch joined #mojo
14:06 dhg joined #mojo
14:08 neilhwatson joined #mojo
14:18 mcsnolte joined #mojo
14:18 CHYC joined #mojo
14:49 zivester joined #mojo
15:09 Kripton joined #mojo
15:10 genio I've made it to the final episode of DareDevil (but I fell asleep not long after starting it last night).
15:11 genio It didn't slow down too much, so overall I'm pleased with this season.
15:11 Grinnz_ most of the episodes were heavy hitters.
15:12 lluad joined #mojo
15:23 jabberwok https://github.com/kraih/mojo-pg/pull/15    -- trying to help others not be as confused as I was, picking up a new module for the first time
15:24 jberger jabberwok: did you see my comment from a day or two ago about http://blog.wlindley.com/2016/03/03/using-mojolicious-templates-with-json/
15:25 jberger you want "to_json" rather than "encode_json" because of double utf8 encoding
15:25 jberger to_json is chars->chars, encode_json is chars->bytes
15:25 jabberwok ahhh, i see now... i shall correct that
15:31 jabberwok done
15:32 jabberwok grazie mon amigos
15:48 disputin joined #mojo
15:52 sri jabberwok: i don't disagree with the idea, but there's lots of typos
15:52 sri and factual errors
15:53 sri like, it's not the controller's helper
15:53 sri it's just a helper
15:53 sri and there is no underlying Mojo::Pg::Database object
15:54 sri there's an underlying pool of Mojo::Pg::Database objects, from which we dequeue one
16:12 jabberwok ok, -- that's why we need this paragraph, to clear these things up.  will revise.
16:15 sri i would start with something like "In this example, we create and use a C<pg> helper to store a L<Mojo::Pg> object."
16:16 sri "And call the method L<Mojo::Pg/"db"> to dequeue a L<Mojo::Pg::Database> object from the connection pool."
16:22 jberger I've been using a pattern lately for my model classes, implemented in the abstract model base class
16:22 jberger has 'pg'; has db => sub { shift->pg->db }; sub query { shift->db->query(@_) }
16:23 jberger that way for sequential queries I just use $model->query(...) and yet I still have $model->pg->db->query if I need it for parallel operations
16:24 jberger and I can use $model->db for say starting a transaction
16:24 pink_mist is db guaranteed not to go stale once you've saved it in your attribute?
16:24 jberger pink_mist: I make the model instance in a request (actually via a helper)
16:24 pink_mist ah
16:24 jberger so it shouldn't
16:25 jberger I wouldn't hold that object for a long time, now
16:25 jberger no
16:30 sri omg, the first macbook rumors sound very bad
16:31 sri apparently they will just make 13" and 15" versions of that new 12" macbook :S
16:32 jberger yay innovation \o/
16:33 sri "thinner than a macbook air"
16:34 sri but at least it will come in neat colors like rose gold -.-
16:52 Rubes joined #mojo
17:05 jzawodn joined #mojo
17:17 PryMar56 joined #mojo
17:32 Rubes joined #mojo
17:40 sri jabberwok: still so many typos :S
17:44 dvinciguerra_ joined #mojo
17:54 sri ok, this is what i had in mind https://github.com/kraih/mojo-pg/commit/cae31756be83cf38eccff76af0b4d7229267e40e
17:56 jberger works for me
17:58 sri jabberwok++
17:59 sri http://mojolicious.org/perldoc/Mojo/Pg#DESCRIPTION
18:28 dod joined #mojo
18:36 glauber joined #mojo
19:15 dhg joined #mojo
19:21 * pink_mist almost never uses ->hash() ... tend to do ->hashes()->[0] if I'm only querying a single row
19:21 sri yea, it's not very useful yet
19:22 Grinnz or ->hashes->first
19:22 sri would be more useful if DBD::Pg could retrieve one row at a time
19:22 sri or retrieve rows in batches
19:23 Grinnz SQLite can, it just makes everything more complicated so I retrieve them all at once anyway
19:23 pink_mist Grinnz: good point, I should use ->first instead of relying on the array-ification
19:23 Grinnz eh, either is ok to rely on
19:23 Grinnz it's not an arrayification, it is an array ref
19:23 Grinnz i just think first looks nicer :P
19:26 mroy joined #mojo
19:27 mroy jberger: t/helper.t is the reason why ForkCall is failing on Windows and not so much the ForkCall module itself. This t/helper.t does the same thing and passes on Windows. https://gist.github.com/marioroy/3de2ec2b8e0ac8042138
19:28 mroy Hurray !!! Your ForkCall module is passing for me on the Windows platform.
19:34 mroy Thank you for Mojolicious. I'm making a cool Mojo::IOLoop::HoboCall interface to MCE::Hobo with support for multiple Hobos and MCE::Shared. Thank you sri. Watching a socket has much lower overhead than polling.
19:36 Rubes joined #mojo
19:49 jberger mroy: I don't understand
19:50 jberger and having the parent callback die is not the same thing as having the deserializer die
19:53 mroy gotcha. well, the deserializer test is the reason for ForkCall failing on Windows.
19:54 jberger what does it do?
19:54 mroy will test again after restoring the file back. Interestingly, bad_deserialize.t passes.
19:55 jberger also, that wasn't the actual problem, the original problem was the mojolicoius.t test, which was the only way I could replicate consistently on windows
19:55 jberger it now passes for no apparent reason
19:55 jberger but I know that in practice it still can abort() on windows, I just can't consistently replicate
19:56 mroy ah. those kind of bugs are hard to fix.
19:57 mroy for t/helper.t, Perl crashes on Windows for the last test.
19:58 jberger what does it say?
19:58 jberger exit in an unusal way?
19:59 mroy I get a Windows popup stating the Perl interpreter has crash. Unfortunately, no output indicating why.
19:59 jberger anyway, in the end I don't want to code my tests around windows bugs, I want them to stay so we know when they are fixed
19:59 mroy Strawberry Perl v5.20.3
19:59 jberger users can and will write code like I did in that test
20:00 jberger making the test pass isn't useful if code like that will still crash the interpreter
20:00 mroy makes sense.
20:00 mroy I misunderstood the last test. Thank you for clarifying.
20:00 jberger I am curious as to why it dies
20:03 mroy It passes if I remove local;  *Mojo::IOLoop::ForkCall::deserializer = sub { sub { die 'argh' } };
20:04 mroy that will overwrite the function. Am not sure why it fails when localized temporarily.
20:04 jberger Ah the local unwind on windows
20:05 jberger Try adding anything else at the end of the test (before done_testing)
20:06 jberger I forget exactly what the local unwind problem was but its a problem
20:06 jberger Basically a free to the wrong pool error
20:06 mroy I added a sleep 1 before exiting the function. And got the following: Attempt to free unreferenced scale: SV 0x3180c2c, Perl interpreter: 0x12ad844 at t.fc\helper.t line 42.
20:07 mroy Met to say added a sleep 1 at the end of the block { ... sleep 1; }
20:07 jberger Not that surprising
20:07 mroy Perl did not crash and all tests passed.
20:08 jberger That's what i originally expected actually :p
20:08 jberger Sigh
20:08 mroy So adding a sleep 1 before leaving the block resolves that one
20:09 jberger Not sure i call that resolved
20:09 * jberger dislikes windows
20:09 mroy ditto -- not easy to make Perl stuff work
20:10 mroy what if saving the original deserialized function to a var and restore afterwards
20:13 mroy that works
20:13 mroy my $orig = \&Mojo::IOLoop::ForkCall::deserializer;
20:13 mroy *Mojo::IOLoop::ForkCall::deserializer = sub { sub { die 'argh' } };
20:13 mroy ... and before leaving the block;  *Mojo::IOLoop::ForkCall::deserializer = $orig;
20:14 mroy no crash without the sleep
20:14 mroy and no warnings/errors
20:18 mroy updated the gist: https://gist.github.com/marioroy/3de2ec2b8e0ac8042138
21:11 mroy thank you jberger. I learned a lot today by going through the test scripts included with ForkCall. Mojo::IOLoop::HoboCall is mostly compatible. It lacks weaken, serializer, and deserializer. IO is managed by MCE::Shared.
21:15 mroy Am quite happy on being able to do Mojolicious + MCE::Hobo + MCE::Shared.
21:16 Grinnz_ I haven't yet had a reason to weaken a forkcall
21:16 Grinnz_ so leaving that out is not really a problem
21:17 melo joined #mojo
21:24 mroy Thank you Grinnz_.
21:29 Rubes joined #mojo
21:31 mroy Will add max_hobos option.  Mojo::IOLoop::HoboCall->new( { num_hobos => 4 }, \&md5_role, [ @args ], sub { callback } );  One channel, thus one read watcher. Basically, am going to remove the ->dequeue_nb and polling from the Mojolicous demonstration: https://gist.github.com/marioroy/b3567d1ccdad5d8a1936
21:31 mroy One watcher (read IO) per unique task.
21:32 mroy Not, per each Hobo worker.
21:45 sugar joined #mojo
21:48 mroy Thank you batman (Mojo::IOLoop::ReadWriteFork), bpmeldey (Mojo::IOLoop::ProcBackground), jberger (Mojo::IOLoop::ForkCall), sri (made suggestion on not polling, but reactor instead whenever possible).
21:49 mroy s/bpmeldey/bpmedley/
22:04 batman not sure why, but you're very welcome :)
22:07 CandyAngel Is there a way of running a bit of code only when daemonising?
22:08 CandyAngel Or should I just peek at @ARGV?
22:09 mroy batman, the Mojo::IOLoop::ReadWriteFork was helpful in learning Mojo::IOLoop.
22:09 sri CandyAngel: think you mean the daemon command, not daemonizing
22:09 CandyAngel sri: Yeah, that's what I meant
22:10 sri this is actual daemonizing https://github.com/kraih/mojo/blob/master/lib/Mojo/Server.pm#L28
22:10 batman mroy: oh. ok... i suck at IPC though :/
22:10 batman mroy: let me know if something looks weird
22:11 sri CandyAngel: and no, there are no hooks
22:11 sri the deplyment method is supposed to be hidden from the app
22:12 CandyAngel Okie, I'll write a custom command. I want to have the server and client in the same app
22:21 mroy batman: I'm very new at this. Mojo::IOLoop::HoboCall is a missing piece and want this to benefit from IO parallelism in MCE::Shared and do Redis-like operations with MCE::Shared->minidb or ->ordhash, ->hash, ->array, or ->queue. Even ->sequence. Lots of possibilities.
22:28 batman good luck. please send a PR to Mojo::Redis2 if that could help
22:31 mroy Was not aware of Mojo::Redis2 until now. MCE::Shared->minidb doesn't talk to Redis, but resembles the Redis API for fast in-memory caching locally.
22:32 batman ok
22:37 mroy Was not aware of Protocol::Redis::XS either. Wow!
22:37 Rubes joined #mojo
22:37 mroy Nice batman. Mojo::Redis2++
22:38 batman thanks. i'm not happy with the module though... was hoping *someone* could make a new version that works like Mojo::Pg
22:38 batman i hope to do that "some day" :/
22:39 Grinnz_ Redis is so different, that I'm not sure how much it could be made like Mojo::Pg, except to make the pubsub more similar
22:41 batman Grinnz_: indeed, but i still want to have the connection pool and the handling of related objects
22:42 batman the issue now is that the main object holds multiple different connections instead of making a new
22:43 Grinnz_ hmm
22:43 batman what i want is to make the main object handle all the atomic operations and then make new objects (and possible connections) for the test
22:43 batman *rest
23:03 dvinciguerra_ joined #mojo
23:32 dhg joined #mojo
23:42 dhg joined #mojo

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