{"action":"closed","issue":{"url":"https://api.github.com/repos/fabric/fabric/issues/556","labels_url":"https://api.github.com/repos/fabric/fabric/issues/556/labels{/name}","comments_url":"https://api.github.com/repos/fabric/fabric/issues/556/comments","events_url":"https://api.github.com/repos/fabric/fabric/issues/556/events","html_url":"https://github.com/fabric/fabric/issues/556","id":3166733,"number":556,"title":"Allow runtime selection of per-task parallelization","user":{"login":"bitprophet","id":6088,"avatar_url":"https://avatars.githubusercontent.com/u/6088?v=3","gravatar_id":"","url":"https://api.github.com/users/bitprophet","html_url":"https://github.com/bitprophet","followers_url":"https://api.github.com/users/bitprophet/followers","following_url":"https://api.github.com/users/bitprophet/following{/other_user}","gists_url":"https://api.github.com/users/bitprophet/gists{/gist_id}","starred_url":"https://api.github.com/users/bitprophet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitprophet/subscriptions","organizations_url":"https://api.github.com/users/bitprophet/orgs","repos_url":"https://api.github.com/users/bitprophet/repos","events_url":"https://api.github.com/users/bitprophet/events{/privacy}","received_events_url":"https://api.github.com/users/bitprophet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fabric/fabric/labels/Core","name":"Core","color":"ededed"},{"url":"https://api.github.com/repos/fabric/fabric/labels/Feature","name":"Feature","color":"40a056"},{"url":"https://api.github.com/repos/fabric/fabric/labels/Network","name":"Network","color":"ededed"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2012-02-10T01:41:18Z","updated_at":"2015-12-07T06:14:41Z","closed_at":"2015-12-07T06:14:41Z","body":"Right now, one can only set parallel behavior like so:\r\n\r\n* Globally, statically, via `env.parallel`\r\n* Per-task, statically, via `@parallel`\r\n* Globally, at runtime, via `-P`/`--parallel` (just sets env var)\r\n\r\nThe missing quadrant is \"per-task, at runtime, via ???\".\r\n\r\nOther runtime per-task tweaks for hosts/roles/host exclusions, are filtered out as \"magical kwargs\", e.g. `fab foo:host=bar` where `bar` is popped and used by `fabric/main.py` to prep a per-task host list. This is *probably* the way to go here as well, as much as I dislike adding more names to the \"invalid kwargs for your own tasks\" list.\r\n\r\nThis should definitely tie into an explicit `parallel=False` kwarg to `execute()` so that users can configure this \"statically\" but per-invocation.\r\n\r\n----\r\n\r\nN.B. A half decent workaround for some use cases (such as the one that caused me to write this issue) is to make sure you use `@runs_once` on the non-parallel task(s). Specifically,\r\n\r\n    $ fab -R rolename -P task_setting_env_vars task_doing_stuff_remotely\r\n\r\nwill misbehave because `task_setting_env_vars` not only gets run once per host (which may or may not be problematic) but because it's run in a subprocess its environmental tweaks never reach `task_doing_stuff_remotely`.\r\n\r\nUsing `@runs_once` on `task_setting_env_vars` appears to correctly disable parallelization for its own execution.\r\n\r\n----\r\n\r\nFor more general applications involving multiple doing-work-remotely tasks, where some need to be run in parallel in an ad-hoc manner and some do not, this problem still needs solving."}}