I think that's clear for me now. Thanks a lot. Mohamed.
On Sun, Jul 15, 2012 at 7:18 PM, Jeff Forcier <[email protected]> wrote: > On Sun, Jul 15, 2012 at 4:02 PM, Mohamed Lrhazi <[email protected]> wrote: >> Thanks Jeff. >> >> If I enable parallel execution, would my disconnect_all() interrupt >> all dispatched ssh sessions, or just the one in my iteration? > > I haven't tested this but I believe the answer is "yes, the latter", > assuming you're calling disconnect_all() inside your task function. > > When execute()* runs a task in parallel, it creates a new subprocess > for each host, and that process gets its own distinct copy of Fabric's > global module state. (In fact, that copy of the cache is emptied > before the subprocess run, so that no external connections end up > shared between parent & children.) > > * Forgot to make this explicit before, but you *must* use the > execute() function for parallelism to work, simply setting > env.parallel and then calling eg run("foo") will not do what you want. > Have to put run() statements inside a function and hand that function > to execute(). > > -Jeff > >> On Sun, Jul 15, 2012 at 6:42 PM, Jeff Forcier <[email protected]> wrote: >>> On Sun, Jul 15, 2012 at 3:31 PM, Mohamed Lrhazi <[email protected]> wrote: >>>> Is this possible? I went through the docs and it does not show any >>>> examples of such usage, only via command line or a decorator. >>> >>> It could be more explicit, but it's in there if you read carefully :) >>> >>> http://docs.fabfile.org/en/1.4.3/usage/parallel.html#command-line-flags >>> >>> "One may also force all tasks to run in parallel by using the >>> command-line flag -P or the env variable env.parallel." >>> >>> So you can tickle env.parallel directly or via 'with settings', and >>> then task executions via execute() will run in parallel. E.g.: >>> >>> with settings(parallel=True): >>> execute(mytaskfunction, hosts=[...]) >>> >>> In addition, decorators are simply functions themselves and can be >>> used to temporarily wrap otherwise un-decorated functions, so you >>> could also: >>> >>> execute(parallel(mytaskfunction), hosts=[...]) >>> >>> Hope that helps, >>> Jeff >>> >>>> >>>> Is there a way? >>>> >>>> Thanks a lot, >>>> Mohamed. >>>> >>>> _______________________________________________ >>>> Fab-user mailing list >>>> [email protected] >>>> https://lists.nongnu.org/mailman/listinfo/fab-user >>> >>> >>> >>> -- >>> Jeff Forcier >>> Unix sysadmin; Python/Ruby engineer >>> http://bitprophet.org > > > > -- > Jeff Forcier > Unix sysadmin; Python/Ruby engineer > http://bitprophet.org _______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
