code: def test_callback_exception(tmpdir, plugin, stop_on_first_crash):
      tmpdir.chdir()
  
      so = Status()
      wf = pe.Workflow(name="test", base_dir=tmpdir.strpath)
      f_node = pe.Node(
          niu.Function(
              function=bad_func, input_names=[], output_names=[]
          ),
          name="f_node",
      )
      wf.add_nodes([f_node])
      wf.config["execution"] = {
          "crashdump_dir": wf.base_dir,
          "stop_on_first_crash": stop_on_first_crash,
          "poll_sleep_duration": 2,
      }
      with pytest.raises(Exception):
          wf.run(
              plugin=plugin,
              plugin_args={"status_callback": so.callback},
          )
  
      sleep(0.5)  # Wait for callback to be called (python 2.7)
      assert so.statuses == [
          ("f_node", "start"),
          ("f_node", "exception"),
      ]
  
file_path: nipype/nipype/pipeline/plugins/tests/test_callback.py
imports: from time import sleep
  import pytest
  import nipype.interfaces.utility
  import nipype.pipeline.engine
label_desc: Use image node_id 4 for calling a global function with example usage: test_callback_exception(tmpdir, plugin, stop_on_first_crash) without return types