Skip to content

Local execution of the .py version of the ttbar analysis is broken #143

@eguiraud

Description

@eguiraud

I switched to local execution by setting AF: local in config.yaml. With that change, python ttbar_analysis_pipeline.py is not able to run. It seems that the problem is linked to running the backend "at global scope": this patch that puts all of the data processing under if __name__ == "__main__" fixes the problem.

The actual error:

    raise RuntimeError('''
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

with this traceback:

Traceback (most recent call last):
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/site-packages/distributed/nanny.py", line 442, in instantiate
    result = await self.process.start()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/site-packages/distributed/nanny.py", line 711, in start
    await self.process.start()
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/site-packages/distributed/process.py", line 55, in _call_and_set_future
    res = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/site-packages/distributed/process.py", line 215, in _start
    process.start()
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
                  ^^^^^^^^^^^^^^^^^
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
           ^^^^^^^^^^^^^^^^^^
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/spawn.py", line 158, in get_preparation_data
    _check_not_importing_main()
  File "/home/blue/Tools/miniconda3/envs/agc-py311/lib/python3.11/multiprocessing/spawn.py", line 138, in _check_not_importing_main

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingimplementationconcerns analysis implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions