add before/after batch hooks
avoid possible hanging if some workers crash