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

IRC log for #mojo, 2017-06-04

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

All times shown according to UTC.

Time Nick Message
00:20 _Janos joined #mojo
00:23 tchaves joined #mojo
00:49 kiwiroy joined #mojo
01:15 aborazmeh joined #mojo
01:35 aborazmeh joined #mojo
02:33 oalders joined #mojo
02:46 noganex joined #mojo
02:53 karjala_ joined #mojo
03:13 oalders joined #mojo
04:01 maschine joined #mojo
04:04 dboehmer joined #mojo
05:27 kaiux joined #mojo
05:48 kaiux joined #mojo
05:48 kiwiroy joined #mojo
06:11 eday joined #mojo
06:48 kiwiroy joined #mojo
07:49 kiwiroy joined #mojo
07:55 Vandal joined #mojo
08:06 Petru_ joined #mojo
08:27 stryx` joined #mojo
09:06 trone joined #mojo
11:48 kiwiroy joined #mojo
11:52 Petru_ joined #mojo
12:03 good_news_everyon joined #mojo
12:03 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vH2xE
12:03 good_news_everyon mojo/master 290af23 Sebastian Riedel: mention a few features too
12:03 good_news_everyon left #mojo
12:03 sri hope it's not too verbose now http://mojolicious.org/perldoc#SPIN-OFFS
12:03 slinkatron joined #mojo
12:07 good_news_everyon joined #mojo
12:07 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vH2xV
12:07 good_news_everyon mojo/master 4a2966a Sebastian Riedel: link to the SQL reference too
12:07 good_news_everyon left #mojo
12:08 pink_mist I think it would be fair to at least mention Mojo::mysql and Mojo::SQLite in the Mojo::Pg section
12:09 sri they are not spin-off projects
12:09 sri the core team has no control over their development
12:11 pink_mist that's why they don't get their own section
12:50 kiwiroy joined #mojo
13:05 Petru_ I have html stored as a string in a variable (it's obtained from converting markdown). How can I display it as html in a template?
13:07 Petru_ sorry, found it. It's %==
13:08 gizmomathboy joined #mojo
13:09 dod joined #mojo
13:14 dod joined #mojo
13:17 _Janos joined #mojo
13:51 PryMar56 joined #mojo
14:40 kiwiroy joined #mojo
14:52 batman sri: the core team has no control over Mojo::mysql..?
14:53 kaare joined #mojo
15:01 Craftsmanship joined #mojo
15:16 jberger not as the core team
15:16 jberger you have control
15:48 kiwiroy joined #mojo
16:06 jberger sri: does a mojo-served websocket automatically respond to ping frames?
16:07 sh14 joined #mojo
16:26 jberger yes, it seems that it should
16:26 jberger https://github.com/kraih/mojo/blob/master/lib/Mojo/Transaction/WebSocket.pm#L76
16:26 jberger ok, gotta check this end
17:01 dod joined #mojo
17:15 Petru_ joined #mojo
18:47 kiwiroy joined #mojo
19:16 Kundun joined #mojo
19:22 zivester joined #mojo
19:41 kaare joined #mojo
19:45 Craftsmanship If I want to wire Text::xSV into my app should I just replace its _print method with something in $tx?
19:48 kiwiroy joined #mojo
19:56 marty joined #mojo
20:01 Craftsmanship ... the method "write" in Mojolicious::Controller
20:02 pink_mist that sounds crazy
20:02 pink_mist but I've no idea what you actually want
20:03 Grinnz when wiring things together, usually you can just put output from one thing into input of the other thing
20:03 Grinnz don't overcomplicate it
20:04 Grinnz i don't really know anything about Text::xSV, i usually just use csv() from Text::CSV
20:04 Grinnz you can set a custom separator of course
20:08 Craftsmanship it has print_row / print_headers that call $self->print ... which just calls regular-old print
20:09 Grinnz then i wouldn't use those methods
20:09 Grinnz that's quite unhelpful
20:10 Grinnz maybe you can tell it to print to a scalar somehow, or at least a filehandle you opened to a scalar?
20:10 Craftsmanship it takes a filename.
20:11 Craftsmanship that's why I was considering sub-classing the method away
20:11 Grinnz i mean, that part's whatever, but don't do raw write stuff on the mojo side, just print your data into an asset then serve the asset normally
20:13 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Rendering#Custom-responses
20:23 jberger Craftsmanship: could this help you? https://metacpan.org/pod/Mojolicious::Plugin::ReplyTable
20:23 Craftsmanship I'm generating the csv content, I don't believe Assets will help with that
20:24 Grinnz why not?
20:24 Grinnz as that link says, assets are exactly how to serve generated content
20:24 Craftsmanship because the examples look wholly unrelated?
20:24 Grinnz well you have to construct the asset first
20:25 Grinnz it would be done differently when generating the content
20:25 jberger wait, Craftsmanship are you serving a file?
20:26 jberger I thought you were using some (in memory) data and rendering it AS csv
20:26 Craftsmanship No, i'm not serving anything from the file system.
20:26 Grinnz like my $asset = Mojo::Asset::Memory->new; some loop generating chunks { $asset = $asset->add_chunk($chunk) }
20:26 Craftsmanship sounds very not-streaming
20:26 Grinnz well yes, you'd use write to stream the response, but why bother
20:26 Grinnz thats significantly more complicated
20:27 jberger Grinnz: what would an Asset do that just rendering data wouldn't?
20:27 Craftsmanship http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Streaming
20:29 Grinnz you have to calculate the content length first anyway
20:30 Grinnz unless you do chunked transfer which is again more complicated
20:31 jberger let's back up
20:31 jberger Craftsmanship: do you need to stream the results?
20:31 jberger ie, are results being generated after earlier results are already sent
20:31 Craftsmanship I'm getting inactivity timeouts at the moment, so it seems like chunked encoding might be a good choice.
20:32 jberger those aren't really related either
20:32 Grinnz you can just increase the inactivity timeout
20:32 Grinnz and possibly use a subprocess to avoid blocking other requests
20:32 jberger does it take longer than the default timeout (15s)
20:32 jberger ... to generate the date
20:33 jberger data
20:33 Grinnz see Mojolicious::Plugin::Subprocess
20:35 jberger Craftsmanship: did you look at my ReplyTable module (posted above)?
20:38 Craftsmanship ReplyTable seems handy,
20:38 jberger and if not (for some reason), see the code for the csv renderer
20:38 Craftsmanship I guess I have to do all the math for my rows ahead of time though
20:40 Craftsmanship jberger: using a drain callback would also prevent blocking other requests though, right?
20:40 jberger are you CPU bound?
20:40 jberger where does the data come from?
20:43 Craftsmanship An earlier route fetches it, and shoves it in the stash, and then I loop over said records and do stuff with them,
20:43 Craftsmanship and I was hoping to be able to present the results as csv
20:44 Craftsmanship it seems like calling $c->write is pretty straight forward.
20:44 jberger but the "do stuff" takes long enough to cause an inactivity timeout
20:44 Grinnz it's straightforward if you already set the content length
20:45 Grinnz mostly
20:45 Craftsmanship or if I chunk, yes.
20:45 Grinnz then you'd use write_chunk
20:45 jberger I still haven't heard anything that makes me think that that is the right solution here
20:46 Craftsmanship Excuse me?
20:46 jberger are you wanting to return rows as they are calculated?
20:46 jberger or do you just want to avoid the timeout
20:46 Craftsmanship I just want to generate a csv of the stuff
20:46 jberger streaming content is a jackhammer to kill a bug
20:46 Craftsmanship i'm not sure why there are pitchforks and Assets and sub processes involved
20:47 Craftsmanship There is only enough kill and not enough kill.
20:47 Craftsmanship Any other distinction is meaningless.
20:47 jberger so the subprocess is what would allow the server to keep serving if the reason it takes so long to process your data is cpu-bound
20:47 jberger ie, blocking
20:48 jberger you'd take your data, use the subprocess to do the work
20:48 jberger then simply render from the subprocess callback
20:49 jberger if you are cpu bound, any other arrangement (streaming/chunked etc) will still block
20:49 jberger it just sends the results at different times
20:50 kiwiroy joined #mojo
20:51 jberger and if you don't care about blocking, then just up the timeout and render normally
20:51 sri or there is a misunderstanding about how streaming works and he just loops endlessly writing chunks to the buffer
20:52 Craftsmanship I'm not doing anything like that at the moment.
20:52 Grinnz it sounds like you think generating assets and using subprocesses are more complicated, but compared to streaming responses they aren't
20:53 Grinnz and also it may not solve your problem
20:54 Craftsmanship http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Chunked-transfer-encoding - you call write_chunk until you're done, then call finish...
20:54 Craftsmanship is that compilcated?
20:54 sri except that's not how it works
20:54 sri you need to recurse and use drain events
20:54 Craftsmanship so, the thing in that example won't work?
20:57 jberger Craftsmanship: can you please take a step back and explain again what you are trying to accomplish?
20:58 Craftsmanship I want to generate a csv of the shit in my stash
20:58 Craftsmanship and i want to learn about streaming
20:58 Craftsmanship and i really don't care of those happen at the same time or not.
20:58 jberger ok, so streaming the results is important to you
20:59 jberger even if just for the learning experience
20:59 Craftsmanship i ...
21:01 Craftsmanship sri: these "Drain events" are just the second argument, right?
21:01 jberger drain callback, yes
21:02 jberger so you can use the callback to control the timing
21:03 Grinnz https://metacpan.org/release/DBOOK/Mojolicious-Plugin-Subprocess-0.002 made it easier to use sereal with it, not sure why i didnt do that before
21:03 jberger to be sure not to write more data until the drain callback fires
21:03 Craftsmanship as in, you only write your data from the callback ...
21:04 Craftsmanship and you let that thing do the iteration over the results ...
21:04 jberger no, but you have to be sure that the callback has happened
21:04 Craftsmanship what?
21:05 jberger are you comfortable with callbacks and related patterns already?
21:05 Craftsmanship Yes.
21:05 Craftsmanship because AnyEvent.
21:05 jberger AnyEvent condvars or real more traditional stuff?
21:06 Craftsmanship Yes.
21:06 jberger the AE condvar pattern doesn't really help you here
21:06 Craftsmanship It's a code ref
21:06 Craftsmanship the thing calls it
21:22 jberger ok, so here is a (contrived) example of how you can write but only after the drain callback has fire, while not writing from the callback itself
21:22 jberger https://gist.github.com/jberger/f5a8e9b6df0d68687411a07fec355e99
21:22 jberger you can use lots of patterns to do that
21:22 jberger this is just the clearest/simplest I could think of quickly
21:24 jberger and, in some sense, that is itself a condition variable, but it isn't how AE does it
21:25 marty joined #mojo
21:27 Craftsmanship You'd just pass the same condvar to the subsequent writes
21:28 jberger but AE's condvar controls the loop
21:28 jberger you can't stop the loop here
21:28 Craftsmanship The one that's pretending to be the mainloop does
21:29 Craftsmanship the rest, where you're not calling recv just happen wihtout blocking
21:29 Craftsmanship 'cause they're just coderefs
21:30 jberger either way, all I'm saying is, something needs to ensure that the drain callback has happened
21:30 jberger whatever does that is up to you
21:30 Craftsmanship Yeah. Thanks for the example.
21:30 jberger (and I forgot to add the finish/empty write)
21:41 stryx` joined #mojo
21:48 kiwiroy joined #mojo
22:12 _Janos joined #mojo
22:16 rshadow joined #mojo
22:34 sri so, i just looked into a Perl 6 book, and guess what, it refers to the language as just "Perl"...
22:35 sri not Perl 6, but Perl
22:35 sri one more reason to be annoyed with the Perl 6 community
22:46 stryx` joined #mojo
23:09 gryphon joined #mojo

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