allow asynchronous pre/post command hooks

also, with this a pre-command-hook can cancel the further
execution of the command by raising an Exception.

cf. issue #395
Merge branch '0.3.4-feature-hooks-563' into testing