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

IRC log for #mojo, 2013-11-23

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

All times shown according to UTC.

Time Nick Message
00:02 rem_lex|pivo joined #mojo
00:43 jberger_ joined #mojo
00:50 KindOne joined #mojo
01:21 mire__ joined #mojo
01:22 * jberger_ sends sri to the moon
01:22 jberger_ ^^ that was about branson
01:22 jberger_ now this: https://gist.github.com/jberger/7609557
01:26 jberger_ it doesn't have all the win-specific handling
01:26 jberger_ which I suspect a true implementation might need
01:27 bpmedley joined #mojo
01:29 sri jberger_: looks like it might just work on windows
01:30 sri i'm actually surprised how small it is
01:30 sri you need to clean up the zombie though
01:31 sri waitpid on close or so
01:31 sri also bind to 127.0.0.1... default is all interfaces
01:34 sri socketpair and Mojo::IOLoop->stream(Mojo::IOLoop::Stream->new($handle1)) might also be a better choice for performance
01:36 sri IO::Socket->socketpair
01:39 jberger_ the AE fork_call isn't that big either
01:39 jberger_ yeah I forgot to reap
01:39 jberger_ and yes I should bind to local
01:39 sri better socketpair
01:39 jberger_ but I'm learning as I go, I don't know about socketpair yet :-)
01:40 sri ok :)
01:40 jberger_ I was proud about getting this far :-D
01:40 sri i'm actually starting to wonder if this is something for core
01:40 jberger_ I'll look into it
01:40 jberger_ would be handy
01:40 * jberger_ might have been trying to nudge for that subtly
01:41 jberger_ but always better to demonstrate and nudge than simple ask-for
01:41 sri for me it would depend on how clean and portable the code ends up
01:41 jberger_ I suspect it would end up looking a bit like the AE code
01:42 jberger_ though, it may not need to get to writing chunks as the server can already handle that
01:42 jberger_ which would clean it up a little
01:43 jberger_ even if it doesn't make mojo core, it might be good enough for a cpan module or at least a blog post
01:43 sri and i'm not sure it could look nice in the ioloop api
01:46 sri Mojo::IOLoop->spawn(sub {...}, sub {...});
01:47 jberger_ oh I see
01:48 jberger_ you would map AE::Util::portable_pipe
01:48 sri i wouldn't go there personally
01:49 sri socketpair is the portable choice
01:52 sri btw. you also need to handle the waitpid status, to detect when your process crashed
01:54 sri the more i think about it the less i like the idea of having it in core ;p
01:54 KindTwo joined #mojo
01:54 jberger_ hehe
01:55 jberger_ that's fine
01:55 sri we'll see once you have a rock solid implementation
01:55 jberger_ I updated the gist
01:55 jberger_ can I put waitpid in the read callback?
01:56 sri i would not do that
01:56 jberger_ that's essentially want AE does, but if the child crashes before writing, what would happen
01:56 sri the socket gets closed when the process dies too, so it always triggers
01:56 sri (the close event)
01:57 jberger_ oh
01:57 jberger_ gotcha
01:57 sri if you do waitpid in the close event you're pretty safe
01:58 jberger_ just updated
01:59 jberger_ that makes a lot more sense
01:59 jberger_ this is definitely a "learn as I go" process
02:00 jberger_ would it be over-pedantic to have the child exit in the close handler too then?
02:00 tholen42 joined #mojo
02:01 sri i would say that's actually necessary
02:02 sri child would never exit if parent goes away
02:03 jberger_ ah, right
02:03 sri first thing i do when i write a new multi processing module, things don't break if the parent dies ;)
02:03 sri *+make sure
02:04 jberger_ these kinds of things look so much better using (event driven) Mojo::IOLoop than when reading the procedural code in AE
02:05 sri ($reader_handle, $writer_handle) = IO::Socket->socketpair( Socket::AF_INET(), Socket::SOCK_STREAM(), Socket::PF_UNSPEC());
02:05 sri that's how you get socketpairs btw
02:05 jberger_ and I could turn those into streams then
02:05 jberger_ is that as portable as servers?
02:06 sri then just my $stream = Mojo::IOLoop::Stream->new($reader_handle) and Mojo::IOLoop->stream($stream)
02:06 jberger_ you mean "or" right?
02:06 jberger_ wait, nm
02:07 jberger_ that's an interestingly polymorphic method
02:08 jberger_ why do the second step there?
02:08 jberger_ once I have the stream, isn't that enough?
02:09 rem_lex joined #mojo
02:09 jberger_ and if you don't mind educating a newbie, why is this more efficient than the server approach? is it just reducing unused and unnecessary overhead?
02:09 sri stream has to be connected to the ioloop
02:10 jberger_ ok
02:10 jberger_ makes sense
02:10 jberger_ I would not have gotten that from the documentation btw
02:10 sri i don't know the implementation details, but socketpair might not require going through a listen socket
02:11 sri in fact, you could use pipe() too, which will give you a socketpair only on windows and a much more efficient pipe elsewhere
02:11 sri in any case, socketpair will be more secure, since there's no active listen socket
02:12 sri even if you bind to 127.0.0.1, you might share the server with others
02:12 jberger_ if pipe is xplatform, why does AE::Util::fork_call go through the portable_pipe shenannigans?
02:12 sri because mlehmann?
02:12 jberger_ nuff said
02:12 jberger_ :-D
02:12 sri https://metacpan.org/release/Child # pipe() seems to work pretty well here
02:13 sri i think most event loops doing this kinda stuff get in trouble because they try to involve signals... which you're luckily avoiding
02:14 sri https://metacpan.org/pod/IO::Pipely # i remember dngor has been fighting with this quite a bit
02:15 sri socketpair() is the first choice for portability, pipe() *maybe* if it's portable enough in the perl versions you support
02:16 jberger_ ok, I will look into it
02:16 sri "socketpair() has been known to have problems on Cygwin."
02:16 jberger_ I have some more reading to do I think
02:16 sri yay!
02:16 jberger_ fun
02:16 sri you're in for a workd of hurt
02:16 sri *world
02:17 sri yea, maybe we shouldn't pull that into core :)
02:18 sri IO::Pipely might be a sensible choice though for you to generate handles
02:19 sri although, i would be interested if with a 5.10.1 dependency socketpair is enough
02:20 sri very interested even, maybe try that first
02:20 * sri nudges jberger
02:21 * jberger_ is nudged
02:22 * sri really needs to finish his job queue
02:22 jberger_ I will have to continue later tho, dinner awaits
02:22 jberger_ job_queue++
02:22 jberger_ sri++
02:23 sri jberger++ # grouphug!
02:31 duncanthrax joined #mojo
02:39 btyler joined #mojo
02:44 Adurah joined #mojo
02:44 bpmedley_ joined #mojo
03:12 sri lindaw on the mojolicious list... that's gonna end well :S
03:15 d4rkie joined #mojo
03:26 marquezc joined #mojo
03:33 d4rkie_ joined #mojo
03:36 russum joined #mojo
03:41 russum left #mojo
03:46 crab what is a lindaw?
04:01 jberger_ sri: https://gist.github.com/jberger/7610638
04:01 jberger_ take 2
04:01 jberger_ and not really for inclusion
04:01 jberger_ but a path to using pipe()
04:01 sri crab: notorious p5p troll
04:02 sri jberger_: haha, that's another way to do it
04:02 * jberger_ starts at the high level :-)
04:02 sri jberger: i think core inclusion is pretty much out of the question already
04:02 sri but it certainly could make for a popular plugin
04:03 jberger_ :-)
04:04 sri Child seems like a perfectly sensible choice
04:05 jberger_ I do have a little apprehension about this quote from Child doc: "NOTE: kill() is unpredictable on windows, strawberry perl sends the kill signal to the parent as well as the child."
04:05 sri yea, signals are a nightmare on windows
04:05 sri took me forever to trial and error the signals for morbo
04:06 sri but i don't think you ever need to call kill anyway
04:06 jberger_ then again, it is what AE does: https://metacpan.org/source/MLEHMANN/AnyEvent-7.05/lib/AnyEvent/Util.pm#L269
04:06 preflex_ joined #mojo
04:07 sri i would let the child finish, and report an error in the parent
04:08 sri "Lost child, it may or may not have finished its work"
04:10 jberger_ if I did that, how would I reap?
04:10 sri that's true... hmm
04:10 abra joined #mojo
04:11 jberger_ nice! I was totally worried that that was a stupid question! (newbie joy)
04:12 Adurah https://twitter.com/lindaw Huh, unexpected.
04:12 sri naah, you're totally right, the blocking waitpid could take way too long
04:13 sri http://www.nntp.perl.org/group/perl.perl5.porters/2013/11/msg209892.html # example
04:16 jberger_ ripping leont is just silly
04:16 sri i recognized the weird avatar from cpan, P got linked all over the place https://metacpan.org/pod/P
04:16 Adurah They do go on.
04:17 jberger_ oh that's how you put it together
04:17 sri sri holmes
04:18 jberger_ she is complaining that pod server is case sensitive
04:18 jberger_ ?
04:19 KindTwo joined #mojo
04:21 sri i never realized how scary baseband processors in cellphones actually are
04:23 sri http://www.osnews.com/story/27416/The_second_operating_system_hiding_in_every_mobile_phone # in case anyone has not seen it yet
04:31 crab sri: oh, linda-w, not lin-daw. heh.
04:31 Adurah Not linux dawg, yeah.
04:38 jberger_ ! "One of the exploits he found required nothing more but a 73 byte message to get remote code execution. Over the air."
04:40 * jberger_ waves at the NSA agent monitoring this via a baseband processor exploit
04:46 jberger_ sri: do I have to remove the streams from the loop?
04:50 sri jberger: nope https://github.com/kraih/mojo/blob/master/lib/Mojo/IOLoop.pm#L236
04:51 sri it's crazy how many components contain their own arm processor and operating system these days... from ssd drives to lightning cables!
04:52 sri fricking cables!
04:54 sri http://www.geek.com/apple/apples-lightning-av-adapter-contains-a-tiny-arm-computer-1541630/
04:55 sri a tiny ios running in the cable
04:59 jberger_ sri: which do you like better (for a cpan module, not core)
04:59 jberger_ fork_call { ... } sub { ... }  # original syntax from AE
04:59 jberger_ or
05:00 jberger_ spawn { ... } then { ... } # where spawn could be any of a number of things
05:00 jberger_ the latter is more like Try::Tiny
05:07 sri then is for futures
05:07 jberger_ hmmm, I suppose that might be confusing
05:09 sri maybe traditional.... my $child = Mojo::IOLoop::Child->new(sub {...}); $child->on(finish => sub {...});
05:10 sri oh, would also need $child->start or so too then
05:10 sri advantage is that you can tie it to a certain ioloop
05:11 sri $child->ioloop(Mojo::IOLoop->new);
05:11 jberger_ https://github.com/jberger/Mojo-IOLoop-ForkCall
05:11 sri you can always put a sugar wrapper around it later
05:12 jberger_ I think no matter which way I go, I would provide fork_call as a migration path
05:12 jberger_ ha, you beat me to it
05:14 Adura joined #mojo
05:17 jberger_ I want to push out a cpan release soonish, because I really want to see the tester results
05:17 jberger_ is anyone on windows? care to test?
05:33 jberger_ oh and I had the argument order wrong from AE
05:36 beyondcreed joined #mojo
05:38 sri btw. mojolicious way is $err as first argument, not in $@
05:39 jberger_ I thought about that, but mojolicious way is also to have a fixed number of arguments
05:39 sri not really
05:39 sri just the first argument being reserved
05:40 sri my ($child, $err, @args) = @_; is something i would do
05:40 sri one such case is delays
05:41 sri well, delays are a bit more complicated, but you get the idea ;p
05:41 jberger_ I do
05:42 jberger_ I'm now torn between being a drop-in for fork_call and being more mojo-consistent
05:42 sri WHY NOT BOTH
05:42 jberger_ WHY NOT ZOIDBERG
05:42 purl (V) (;,,;) (V)
05:43 sri \o/
05:43 jberger_ hahaha
05:43 * sri hugs purl
05:43 * purl nibbles sri's elbow
05:45 jberger_ yeah, I think I'm coming around to fork_call being a wrapper for something with a more mojo feel
05:48 jberger_ would you ever have more that one Mojo::IOLoop?
05:48 btyler joined #mojo
06:04 jberger_ ok, looky now: https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/master/lib/Mojo/IOLoop/ForkCall.pm
06:04 hummeleBop joined #mojo
06:06 jberger_ I could probably make the serialize/deserialize handers pluggable now too!
06:24 jberger_ nice
06:29 jberger_ sri: I started to get global destruction warnings if I didn't have this line: https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/master/lib/Mojo/IOLoop/ForkCall.pm#L56
06:43 Adura joined #mojo
06:53 mfontani joined #mojo
06:57 Vandal joined #mojo
07:06 ZadYree joined #mojo
07:06 mfontani joined #mojo
07:50 jamesw joined #mojo
07:51 KindTwo joined #mojo
08:05 dod joined #mojo
08:25 dod joined #mojo
08:38 dotandimet joined #mojo
09:21 sh4 joined #mojo
09:33 dotandimet joined #mojo
10:00 zivester joined #mojo
10:15 punter joined #mojo
10:28 dotandimet joined #mojo
10:31 dotandimet joined #mojo
10:44 KindTwo joined #mojo
11:18 trone joined #mojo
11:37 zivester joined #mojo
11:48 sh4|2 joined #mojo
12:03 zivester joined #mojo
12:07 KindTwo joined #mojo
12:28 trone joined #mojo
12:30 athenot joined #mojo
12:44 zivester joined #mojo
12:45 denis_boyun joined #mojo
13:04 asarch joined #mojo
13:31 mire__ joined #mojo
13:36 lammel2 joined #mojo
14:07 sri jberger: your read code is dangerous, there is no guarantee whatsoever that you'll receive the whole frozen data structure in one operation
14:13 lammel2 left #mojo
14:24 jberger_ the whole code seems dangerous as I read it this morning
14:25 jberger_ actually, I'm starting to think that I can't use Child
14:25 jberger_ https://metacpan.org/source/EXODIST/Child-0.009/lib/Child.pm#L72
14:25 sri DANGER ZONE
14:26 jberger_ or else, the code the child shouldn't have IOLoop watcher
14:26 jberger_ s
14:28 jberger_ is there an easy way to collect all of the bytes on read, or should I just append them to some buffer?
14:29 jberger_ and then do all the work in the close handler
14:29 jberger_ (this becomes more and more like AE again)
14:36 jberger_ sri: better? https://github.com/jberger/Mojo-IOLoop-ForkCall/blob/master/lib/Mojo/IOLoop/ForkCall.pm#L56
14:37 jberger_ oops and forget the line number, that wasn't important
14:44 jberger_ looks better to me
15:14 sri jberger: i don't get why the child uses an ioloop anyway
15:15 sri you could do everything blocking there
15:43 jberger_ and I do now
15:44 jberger_ at one point I thought the drain event was going to help me
15:50 sri jberger: one last thing, you might want to handle thaw failing
15:50 sri in case the child dies in between writes
15:55 denisboyun joined #mojo
15:55 dotandimet joined #mojo
16:06 jberger_ I suppose that's true
16:14 beyondcreed joined #mojo
16:24 jberger_ better?
16:34 sri better
16:39 hrupp joined #mojo
16:55 jberger_ I'm trying to decide ... I don't really need that do-block do I/
16:55 jberger_ ?
16:59 jberger_ gone
17:01 sri DANGER ZONE
17:01 d4rkie joined #mojo
17:01 * sri just likes saying that
17:02 sri http://www.youtube.com/watch?v=_7HkG6OSo3E
17:04 jberger_ nice
17:06 jberger_ from http://p3rl.org/: "The use of any camel image with the topic of Perl is a trademark of an American media company. Fortunately, the image in the top right corner is just a photoshopped monkey. :-)"
17:06 jberger_ hehe
17:06 jberger_ I usually use p3rl for hot-linking, but it was down earlier
17:06 jberger_ so I pulled up the main site to see if it was back
17:12 * jberger_ gets scared, puts back do block
17:17 d4rkie joined #mojo
17:23 jberger_ is anyone on windows? could you please test?
17:23 jberger_ https://github.com/jberger/Mojo-IOLoop-ForkCall
17:33 voegelas joined #mojo
17:47 dotandimet joined #mojo
17:50 dvinciguerra joined #mojo
18:07 rem_lex joined #mojo
18:10 dotandimet joined #mojo
18:11 gryphon joined #mojo
18:43 btyler joined #mojo
18:53 bowtie_ joined #mojo
18:58 voegelas left #mojo
19:11 Mike-PerlRecruiter_ joined #mojo
19:13 stig joined #mojo
19:31 btyler joined #mojo
20:03 jberger_ joined #mojo
20:38 zivester joined #mojo
20:40 Adura https://gist.github.com/anonymous/7619644 jberger_
20:47 jberger_ Adura, thanks
20:47 Adura I'm going to attempt cygwin's perl, even.
20:47 jberger_ I actually was finally able to fire it up on my work box and I got a similar thign
20:48 Adura Oh, hah.
20:48 jberger_ that would be really interesting
20:48 jberger_ my work box is really locked down though, so I wasn't sure if it was expected or not
21:21 dotandimet joined #mojo
21:28 sri DANGER ZONE
21:36 Adura Less buggy on cygwin 5.14.
21:38 Adura A pass, even.
22:08 beyondcreed joined #mojo
23:05 ronsavage joined #mojo
23:50 KindTwo joined #mojo

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