šŸ¦‹ Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
00:24 MasterDuke left
tbrowder Voldenet: i'm taking the easier path and using a separate prog to do the queryi think i can get that to work with help from brian's and jmerelo's books along with our docs 00:35
01:03 MasterDuke joined 01:18 MasterDuke left 01:24 kylese left, hulk joined
guifa o/ 02:00
antononcube 😓 02:04
02:15 hulk left, kylese joined 02:18 apac joined, Aedil joined 02:52 apac left 02:57 xinming joined 04:30 kylese left 04:34 kylese joined 04:35 Aedil left 04:58 Aedil joined 05:30 kylese left, kylese joined 05:37 andinus2 left 05:38 andinus joined 05:59 Sgeo left 06:35 abraxxa-home joined 06:37 abraxxa-home left 06:38 abraxxa-home joined 07:15 jpn joined 07:21 lizmat joined 07:25 jpn left 08:04 nine left, nine joined 08:19 jpn joined 08:25 abraxxa-home left 08:41 wayland76 joined 08:47 lichtkind joined 09:17 lizmat left 09:28 jpn_ joined, jpn left 11:04 Aedil left 11:14 Aedil joined 11:30 JimmyZhuo joined
tbrowder \o 11:35
11:52 apac joined 12:39 JimmyZhuo left 12:40 apac left 12:42 grondilu left 12:45 grondilu joined
tbrowder well, i'm out of airspeed and ideas for putting a timeout on a proc that is hanging. unless someone can help, i'm considering using posix cmd "posix_spawn". i'll put my latest attempt in a gist later and link it here. 12:45
antononcube Try to dive in deeper and some ideas my baloon up. 12:46
@tbrowder I strongly suspect "out of airspeed" is aviation jargon. 12:48
tbrowder i think redefining stdin somehow may help
antononcube: roger 12:49
antononcube šŸ™‚ šŸ‘
tbrowder but i haven't done posix spawn in a looong time. can we redirect stdin within a raku process somehow? 12:50
my fiddling with $*IN has not worked. 12:51
nahita3882 tbrowder: are you interested in a NativeCall based solution? I did this paste.debian.net/1368690/ for Windows, and i'm 84% sure similar functionalities exist in the GNU/Linux world to interface with 12:56
jdv tbrowder: what is the problem? if you said it its beyong my scrollback buffer
nahita3882 in fact someone mentioned Terminal::ReadKey which may or may not be a bridge to, e.g., termios found in POSIX systems
tbrowder ah, just found method .close-stdin...trying again 13:06
13:09 JimmyZhuo joined 13:12 jpn_ left 13:16 oodani_ left, oodani joined 13:20 JimmyZhuo left
tbrowder the problem is i'm trying to implement a time-delay in a test for a raku CLI program that asks for a yes or no reponse to a prompt. the program hangs and ties up stdin. i would like to kill the program after a defined time delay. 13:23
i have to go but i will gist it and link here shortly 13:24
here's the gist 13:36
<script src="gist.github.com/tbrowder/43b914053...script>
sorry, bad link!! 13:37
gist.github.com/tbrowder/43b914053...ede05f2a3d 13:38
that's it ^^ 13:39
bye for now
13:40 wayland76 left 13:41 wayland76 joined 14:02 jpn joined 14:07 jpn left
tbrowder hm, i wonder if i need one of Terminal distros would help? note i can manually run the tests, but i would like to see it automated. surely current raku can do that with the experts here. 14:12
14:13 jpn joined 14:37 Sgeo joined
tbrowder oh, i see module Proc::Async::Timeout! that may be the answer... 15:07
[Coke] tbrowder: is the goal to prompt the user and then give up if they don't respond in X seconds? 15:08
jdv uh, don't you need a whenever in a react? 15:09
tbrowder yes, @gfldex's module looks like it should do what i need
jdv maybe getting a feel for raku async stuff would be a good place to start:)
tbrowder well, yes, and it's not easy to grok for me... 15:11
[Coke] gist.github.com/coke/339dd6b215111...fc29d94ece 15:19
^^ there's a short example that prompts for input, prints it out immediately if you enter it, and otherwise emits "timeout" in 5 seconds. 15:20
tbrowder thnx! 15:24
[Coke] And that's all standard raku, same process.
Hope it helps!
Neary identical to docs.raku.org/type/Promise#method_in - but if you didn't know to look for that method... 15:25
I find that easier to parse mentally than the react/whenever, but you could probably implement something there with an interval of 5s also. 15:26
ugexe timing out processes is hard and doing it in raku probably doesnt do what you think it does 15:28
Proc::Async::Timeout as well as the example [Coke] posted will just stop waiting for the process. they do not kill the process
given that, i don't expect that stopping waiting for the process is going to e.g. give back $*IN 15:29
[Coke] might be an xy problem if he's just trying to get the prompting working in raku 15:30
If you still need to be calling out to external processes, definitely work more work to do.
-> afk 15:33
ugexe m: my $proc-promise = start { shell q|sleep 3; echo 42;| }; my $timeout-promise = Promise.in(1).then({ say "timeout" }); await Promise.anyof($proc-promise, $timeout-promise); sleep 5; 15:34
camelia timeout
42
ugexe see this example where we "timeout" but the process (that is still alive) outputs to $*OUT
maybe my example is a bit too naive since it does not use $proc.kill like Proc::Async::Timeout 15:36
gfldex Proc::Async::Timout does `signal => Signal::SIGKILL`. However, there is no error handling on that part because of ... Windows. 15:37
tbrowder gfldex: would you consider a pr to modernize that distro to use mi6 management and github workflows 3 os testing? 16:02
for my use case all i need is for the code to run as a t/test and not hang. i do more real testing in other test files. 16:06
16:26 eseyman left 16:29 manu_ joined 17:04 manu_ is now known as eseyman 17:43 jpn left 17:47 stanrifkin joined 19:00 wayland joined 19:01 wayland76 left
tbrowder so far Proc::Async::Timeout hasn't worked for my use case. going to try [Coke]'s nextit would be cool for someone to create a raku distro emulating posix_spawn. that way i thnk the proc status should be able to be queried even though it's hanging 19:20
19:21 jpn joined
ugexe if the process is hanging what status can it possibly have 19:23
19:26 jpn left
tbrowder i think there is a way to get the hanging status using one of the linux tools 19:28
top maybe? 19:29
jdv maybe you mean "PROCESS STATE CODES" like ps exposes 19:31
ugexe in the context of spawning process i'm not sure process state codes would be relevant either (if those are what i think they are) since it is presumably always going to be "running" 19:33
as far as a typical status / exit code... the process obviously needs to exit first 19:34
jdv its also at 'grep ^STATE: /proc/$PID/status' etc
i guess if you wanted fancy "why didn't this do as expected" it could be useful 19:35
but aside from troubleshooting running procs with ps i've never used it elsewhere. idk.
tbrowder that's ok, at least one could check time which would give a clue. i know that's not a perfect solution, but it's an aid
jdv: because i was not thinking about it until now 19:36
ugexe a long running process is running succesfully. there is no "hanging" status
jdv well, a proc can get "stuck" in "uninterruptible sleep" 19:37
tbrowder yes but at least you can tell it exists without hanging my raku prog tests
jdv blocking sockets can be a pain sometimes
ugexe i guess im confused because spawning processes doesnt have to hang anything, and you already know how long the process has been running because your code spawned it 19:38
jdv feels oddly tangenty. i'd maybe backup and reasses the end goal and the means you want to spend time doing it 19:39
tbrowder but i haven't been able to "see' the hang and exit gracefully from the test 19:40
automated test--i guess it's impossible 19:41
ugexe it sounds like you are trying to "see" it wrong if you tried Proc::Async::Timeout and expected the status code to show you something
tbrowder no, i expected it would die-ok {} 19:42
19:42 MoC joined
ugexe it should, as i see it returns a failure X::Proc::Async::Timeout 19:43
tbrowder i couldn't get that response
i'll dbl check the code... 19:44
ugexe show your code
raku -MProc::Async::Timeout -e 'my $proc = Proc::Async::Timeout.new("sleep", 10); react { whenever $proc.start(timeout => 1) { QUIT { when X::Proc::Async::Timeout { say "timed out" }; }; say "started" }; };' 20:00
works for me
tbrowder gist.github.com/tbrowder/5895bf396...9392494630 20:07
it's probably not clear here, but in the code, the user is expected to answer the response. for normal testing there is a 'force' option to bypass that. 20:09
20:12 skyesoss joined
tbrowder it's not an essential test, but it itches 'cause i want to make it work! 20:13
ugexe Proc::Async.new( 20:14
you are supposed to be using Proc::Async::Timeout.new() to start
tbrowder CRUD fixing, trying locally... 20:16
ugexe secondly you are catching the exception and not rethrowing it, so dies-ok never gets to see it
just remove the catch block
20:17 jpn joined 20:21 jpn left
tbrowder ok... 20:25
ugexe: still hanging waiting for user input. thanks very much for your help (and good eye balls!!). i'm gonna forget using this test for now. 20:30
20:32 skyesoss left 20:49 MasterDuke joined 20:59 MasterDuke left
grondilu m: class Foo { method talk { say "hi" } }; talk Foo.new: 21:10
camelia hi
ugexe raku -MProc::Async::Timeout -e 'my $proc = Proc::Async::Timeout.new($*EXECUTABLE, "-e", "prompt q|input data please|"); react { whenever $proc.start(timeout => 1) { QUIT { when X::Proc::Async::Timeout { say "\ntimed out" }; }; say "started" }; };'
input data please
timed out
doesn't hang for me when the process is awaiting user input
21:10 MasterDuke joined
grondilu function-like method calls don't work in the REPL, do they? 21:11
librasteve nope - look the repl is pretty handy but not definitive - suggest try raku -e 'class Foo { method talk { say "hi" } }; talk Foo.new:' 21:16
m: 'class Foo { method talk { say "hi" } }; talk Foo.new: 21:17
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Unable to parse expression in single quotes; couldn't find final "'" (corresponding starter was at line 1) at /home/glot/main.raku:1 ------> ethod talk { say "hi" } }; talk Foo.new:ā<EOL> expecting any of: single quotes statement list term
evalable6 (exit code 1) ===SORRY!=== Error while compilin…
librasteve, Full output: gist.github.com/5472ead7ff9ce661a2...3442080b09
librasteve m: class Foo { method talk { say "hi" } }; talk Foo.new:
evalable6 hi
Raku eval hi
grondilu that works here but not on my repl 21:25
grondilu tries again
tbrowder ugexe: in my code i assign the prompt response to a $res var. maybe i can work around that some way..,
i don't just expect a response, i need to evaluate it 21:27
21:28 guifa left 21:30 sorenson left 21:31 sorenson joined
librasteve grondilu: the repl is not able to do this (or a few other things) - the repl is handy, but it does not always work ... use the repl to quickly experiment, but do not expect it to work more than 90% of the language ... it is improving all the time btw but for now you need to use the compiler (as I have shown above) for 100% coverage 21:38
21:42 jpn joined 21:47 jpn left
that said, you may want to make an issue on this in the repl repo so that someone can go in and fix it! 21:47
21:53 MasterDuke left 21:55 lizmat joined 22:17 lichtkind left 22:29 MoC left 22:30 lizmat left 22:37 Aedil left 23:34 tejr left 23:40 tejr joined