Getting the status of running shreds *into* chuck
Hi I'm working on my chuck live setup again, and have a question I'm fairly sure I asked a (long) while ago: Is it possible to get the status of the VM inside a piece of chuck code? Machine.status() does the same as chuck --status, which is printing the info I need, but unfortunately to a terminal outside of chuck. The thing is, I'm sporking a lot of files from my code, and I need to keep track of which of them are still running at certain points... If this is not directly possible, does anyone have an idea for a hack? If anything else fails I think I might roll up my sleeves and hack in the chuck source, but that the last resort, since I'm not really speaking C++ that fluently... -- Atte http://atte.dk http://modlys.dk
Hey Atte,
If this is not directly possible, does anyone have an idea for a hack?
Shred objects have a .running() and a .done() member function. Those might cover your usage case? Rather cludgy workaround; you could have the VM pipe its output to a file, then create a chuck function that would clear the file, call for the VM status using Std.system( "chuck --status)", then read the file. This would be rather slow. It's odd that this seems so hard. Maybe we need to re-think the status stuff. I'd like to also repeat that I feel it'd be useful of the chuck command, when connecting to a already running VM, would return the result of it's operation, instead of printing it to the VM's window. It seems that while convenient for human readers the place where the status gets returned is rather inconvenient for reading by processes. Yours, Kas.
Kas, Have you ever gotten this working? I've tried it and it seems there's a problem with the way chuck buffers its output. The status lines don't come out until the process ends. The only way I've been able to read the status line without stopping the VM is to run chuck inside of GNU screen and log its output (screen -L chuck --loop), and tail the log file, but I don't know how to configure screen to make it constantly log its output; it seems to only log periodically, so there's a delay until you see the status output. I've tried a few different things with appending to files or writing to FIFOs but the way the chuck command writes its output always seems to pose a stumbling block. -jordan chuck version: 1.2.1.4-beta-1 (dracula) exe target: mac os x : universal binary On Sunday, July 8, 2012 at 2:25 PM, Kassen wrote:
Hey Atte,
If this is not directly possible, does anyone have an idea for a hack?
Shred objects have a .running() and a .done() member function. Those might cover your usage case?
Rather cludgy workaround; you could have the VM pipe its output to a file, then create a chuck function that would clear the file, call for the VM status using Std.system( "chuck --status)", then read the file. This would be rather slow.
It's odd that this seems so hard. Maybe we need to re-think the status stuff. I'd like to also repeat that I feel it'd be useful of the chuck command, when connecting to a already running VM, would return the result of it's operation, instead of printing it to the VM's window. It seems that while convenient for human readers the place where the status gets returned is rather inconvenient for reading by processes.
Yours, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu (mailto:chuck-users@lists.cs.princeton.edu) https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 2012-07-08 20:25, Kassen wrote:
Hey Atte,
Hey Kassen, thanks for your reply!
If this is not directly possible, does anyone have an idea for a hack?
Shred objects have a .running() and a .done() member function. Those might cover your usage case?
But that won't work when adding a file to the VM, right? I'm doing something like Machine.add(filename) => id; if(id != 0){ id => running_patterns[i].id; filename => running_patterns[i].filename; nb_running_patterns + 1 => nb_running_patterns; } else { <<<"NOT ABLE TO LOAD FILE",filename,"-----------">>>; } So all I have left after the file is added is it's id. What you suggest is working when sporking a function or other piece of code (example from the manual) // spork another, store reference to new shred in offspring spork ~ go() => Shred @ offspring;
Rather cludgy workaround; you could have the VM pipe its output to a file, then create a chuck function that would clear the file, call for the VM status using Std.system( "chuck --status)", then read the file. This would be rather slow.
That doesn't seem to work. I did a redirect of my main chuck-starter-scripts output to a file like this: run holde_pkt/ > status.txt 2>&1 And some info gets into the file, however not the result of chuck ^ or doing Machine.status() fro the chuck code :-( -- Atte http://atte.dk http://modlys.dk
Atte;
But that won't work when adding a file to the VM, right? I'm doing something like
No, it won't. I think the only way to get a (non-degenerate) Shred object is to link it to a sporked shred. Functionality-wise that's fine, in practice we'll probably use multiple files.
That doesn't seem to work. I did a redirect of my main chuck-starter-scripts output to a file like this:
run holde_pkt/ > status.txt 2>&1
And some info gets into the file, however not the result of chuck ^ or doing Machine.status() fro the chuck code :-(
Ah. So my thought experiment sucks. To be honest this was such a roundabout and impractical way to do it that I didn't even anticipate anyone would try it (I didn't). I should have realised that such trivial details don't discourage present company ;-) Ok, what should proper functionality look like? How about these; int[] Machine.runningShreds() returns a array of integers, representing all currently running shreds in ascending order int Machine.running(int shred_id) returns 1 if shred_id is currently running on the VM, 0 otherwise Would those leave any usage case uncovered or cause issues otherwise? I don't think they could be hard to write, we could peek in the status function to see where the data comes from. Yours, Kas.
On 2012-07-08 21:11, Kassen wrote:
How about these;
int[] Machine.runningShreds() returns a array of integers, representing all currently running shreds in ascending order
int Machine.running(int shred_id) returns 1 if shred_id is currently running on the VM, 0 otherwise
Would those leave any usage case uncovered or cause issues otherwise?
That would be fine for my usage, yes!
I don't think they could be hard to write, we could peek in the status function to see where the data comes from.
That sounds promising! Which reminds me: how's the development of chuck like these days? Is there a repo somewhere where things are happening? I'm still running the official 1.2.1.3 with a handful of patches I made myself to make it compile on my arch box + various things that annoyed me... -- Atte http://atte.dk http://modlys.dk
On 2012-07-08 21:11, Kassen wrote:
int Machine.running(int shred_id) returns 1 if shred_id is currently running on the VM, 0 otherwise
Obviously I'm not clever enough to make it work. [test.ck]:line(4): class 'Machine' has no member 'running' I think the functionality of the function is ok, but obviously I don't know how to add this new function to the list of member functions of class Machine :-( Any hints? -- Atte http://atte.dk http://modlys.dk
Atte;
I think the functionality of the function is ok, but obviously I don't know how to add this new function to the list of member functions of class Machine :-(
Any hints?
What I'd do would be taking one of the functions that is already there and tracing where it gets defined using grep (or a similar cross file searcher) and copy-pasting that stuff with the name of the new function. That strategy has served me well elsewhere, no actual knowledge of C++ is needed ;-) if you get stuck I'll help in a day or two, currently I urgently need to sit on the floor, play a 2d game with my GF and sip Dutch gin. It's my birthday, so I can ;-) Cheers, Kas.
On 2012-07-09 23:59, Kassen wrote:
What I'd do would be taking one of the functions that is already there and tracing where it gets defined using grep (or a similar cross file searcher) and copy-pasting that stuff with the name of the new function. That strategy has served me well elsewhere, no actual knowledge of C++ is needed ;-)
I already got a bit further, but am a bit confused. Will go on though...
if you get stuck I'll help in a day or two,
That sounds great, will let you know how it goes...
currently I urgently need to sit on the floor, play a 2d game with my GF and sip Dutch gin. It's my birthday, so I can ;-)
...that sounds even better! Happy birthday! -- Atte http://atte.dk http://modlys.dk
participants (3)
-
Atte André Jensen
-
Jordan Orelli
-
Kassen