This commit adds code to detect if the task is running synchronously in the worker and re-raise exceptions that were originally raised by the underlying task function.