/srv/irclogs.ubuntu.com/2013/05/19/#juju-dev.txt

thumpermorning folks21:57
=== racedo` is now known as racedo
thumperdavecheney: hi23:20
thumperdavecheney: I have some go questions for you23:21
thumperdavecheney: got some time?23:21
davecheneythumper: shoot23:21
thumperdavecheney: 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't23:22
thumperthe Command object doesn't allow a timed wait23:23
thumperand I want the outer function to gather the results23:23
davecheneythumper: no, you should spin off a goroutine to do this23:23
davecheneyi *believe* that worker/uniter already does exactly this23:23
thumperhmm...23:23
thumperI know that it should be theoretically possible23:24
thumperbut I'm struggling with the go routine structure, and communication using tombs23:24
thumpersince the os/exec package doesn't have a timed wait23:24
thumperonly a definite wait23:24
thumperso we need more go routines, yes?23:24
davecheneyyou23:24
davecheneyyup23:24
davecheneyi think something that sits in select { case <-tomb.Dying: // everything is fine, exit ; case <- timeout: cmd.Kill()23:25
thumpersince I'm wanting to simultaneously run X commands in parallel23:26
thumperI have a feeling I need multiple tombs23:26
thumperand can't really do with one23:26
davecheneythis is going to need some scaffolding23:27
* thumper nods23:27
thumperlet me explain what this is for23:27
thumperI want to have "juju help plugins"23:28
thumperit will call "juju-<pluginName> --description" for each plugin23:28
thumperbut it only waits 1s (or some value)23:28
thumperand if the plugin takes too long to return23:28
thumperit kills it and says "took too long to respond"23:28
thumperthat way we can gather descriptions for all plugins in ~1s23:29
thumpermake sense?23:29
davecheneyyup23:29
davecheneyif you want to wait on multiple goroutines, the common pattern is a fan in via a channel23:29
thumperI have a method that returns []string for all the plugins it found23:30
thumperright23:30
thumperI got that far :)23:30
thumperit is the timed killing and appropriate waits that I'm struggling with23:30
thumperI feel that given enough time (like hours this afternoon), I could come up with something hackish23:31
thumperbut was wonering if you had a more concise solution in less time :)23:31
davecheneygimme a few mins to sketch something out23:31
thumperta23:31
thumperI have a test framework that I can plug the method into already23:32
thumperyay tests23:32
thumperdavecheney: I'm going to leave shortly for the gym, but will check back in when I return :)23:44
davecheneythumper: nearly done23:45
davecheneyi have something working23:45
thumperdavecheney: that's awesome!23:48
davecheneythumper: http://play.golang.org/p/3Avy6eHj4K23:50
davecheneywhat I have so far23:50
thumperok, I'll plug it in to my testy things and check back after lunch23:52
thumperjust putting gym shoes on23:52
thumperand thanks23:52

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!