thumper | morning folks | 21:57 |
---|---|---|
=== racedo` is now known as racedo | ||
thumper | davecheney: hi | 23:20 |
thumper | davecheney: I have some go questions for you | 23:21 |
thumper | davecheney: got some time? | 23:21 |
davecheney | thumper: shoot | 23:21 |
thumper | davecheney: I want to run a collection of commands in parallel, and have each of those commands execute another app, however instead of waiting for it to definitely finish, wait for a defined time, and return the combined output if it finished and something else if it didn't | 23:22 |
thumper | the Command object doesn't allow a timed wait | 23:23 |
thumper | and I want the outer function to gather the results | 23:23 |
davecheney | thumper: no, you should spin off a goroutine to do this | 23:23 |
davecheney | i *believe* that worker/uniter already does exactly this | 23:23 |
thumper | hmm... | 23:23 |
thumper | I know that it should be theoretically possible | 23:24 |
thumper | but I'm struggling with the go routine structure, and communication using tombs | 23:24 |
thumper | since the os/exec package doesn't have a timed wait | 23:24 |
thumper | only a definite wait | 23:24 |
thumper | so we need more go routines, yes? | 23:24 |
davecheney | you | 23:24 |
davecheney | yup | 23:24 |
davecheney | i think something that sits in select { case <-tomb.Dying: // everything is fine, exit ; case <- timeout: cmd.Kill() | 23:25 |
thumper | since I'm wanting to simultaneously run X commands in parallel | 23:26 |
thumper | I have a feeling I need multiple tombs | 23:26 |
thumper | and can't really do with one | 23:26 |
davecheney | this is going to need some scaffolding | 23:27 |
* thumper nods | 23:27 | |
thumper | let me explain what this is for | 23:27 |
thumper | I want to have "juju help plugins" | 23:28 |
thumper | it will call "juju-<pluginName> --description" for each plugin | 23:28 |
thumper | but it only waits 1s (or some value) | 23:28 |
thumper | and if the plugin takes too long to return | 23:28 |
thumper | it kills it and says "took too long to respond" | 23:28 |
thumper | that way we can gather descriptions for all plugins in ~1s | 23:29 |
thumper | make sense? | 23:29 |
davecheney | yup | 23:29 |
davecheney | if you want to wait on multiple goroutines, the common pattern is a fan in via a channel | 23:29 |
thumper | I have a method that returns []string for all the plugins it found | 23:30 |
thumper | right | 23:30 |
thumper | I got that far :) | 23:30 |
thumper | it is the timed killing and appropriate waits that I'm struggling with | 23:30 |
thumper | I feel that given enough time (like hours this afternoon), I could come up with something hackish | 23:31 |
thumper | but was wonering if you had a more concise solution in less time :) | 23:31 |
davecheney | gimme a few mins to sketch something out | 23:31 |
thumper | ta | 23:31 |
thumper | I have a test framework that I can plug the method into already | 23:32 |
thumper | yay tests | 23:32 |
thumper | davecheney: I'm going to leave shortly for the gym, but will check back in when I return :) | 23:44 |
davecheney | thumper: nearly done | 23:45 |
davecheney | i have something working | 23:45 |
thumper | davecheney: that's awesome! | 23:48 |
davecheney | thumper: http://play.golang.org/p/3Avy6eHj4K | 23:50 |
davecheney | what I have so far | 23:50 |
thumper | ok, I'll plug it in to my testy things and check back after lunch | 23:52 |
thumper | just putting gym shoes on | 23:52 |
thumper | and thanks | 23:52 |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!