Page MenuHomePhabricator

Training mwaddlink causes an AttributeError: 'NoneType' object has no attribute 'kill' error
Closed, ResolvedPublicBUG REPORT

Description

This something happens when running a training pipeline for mwaddlink:

Traceback (most recent call last):
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/virtual_packages/cuda.py", line 45, in cuda_version
    detector.start()
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/spawn.py", line 134, in _check_not_importing_main
    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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/srv/home/sgimeno/research-mwaddlink/src/scripts/generate_anchor_dictionary_spark.py", line 134, in <module>
    spark = create_session(
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/wmfdata/spark.py", line 217, in create_session
    return create_custom_session(
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/wmfdata/spark.py", line 115, in create_custom_session
    conda_packed_file = conda.pack(**conda_pack_kwargs)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/wmfdata/conda.py", line 95, in pack
    elif is_active():
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/wmfdata/conda.py", line 60, in is_active
    if active_prefix() is None:
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/wmfdata/conda.py", line 41, in active_prefix
    return info().get("active_prefix", None)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/wmfdata/conda.py", line 27, in info
    return json.loads(condacli("info", ["--all", "--json"])[0])
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/cli/python_api.py", line 122, in run_command
    raise e
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/cli/python_api.py", line 111, in run_command
    result = do_call(args, p)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/cli/conda_argparse.py", line 205, in do_call
    result = getattr(module, func_name)(args, parser)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/cli/main_info.py", line 559, in execute
    renderer = InfoRenderer(context)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/cli/main_info.py", line 420, in __init__
    self._info_dict = get_info_dict()
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/deprecations.py", line 174, in inner
    return func(*args, **kwargs)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/cli/main_info.py", line 223, in get_info_dict
    _supplement_index_with_system(virtual_pkg_index)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/deprecations.py", line 118, in inner
    return func(*args, **kwargs)
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/core/index.py", line 804, in _supplement_index_with_system
    for package in context.plugin_manager.get_virtual_package_records():
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/manager.py", line 405, in get_virtual_package_records
    for hook in self.get_hook_results("virtual_packages")
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/manager.py", line 236, in get_hook_results
    plugins = [item for items in hook(**kwargs) for item in items]
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/manager.py", line 236, in <listcomp>
    plugins = [item for items in hook(**kwargs) for item in items]
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/virtual_packages/cuda.py", line 66, in conda_virtual_packages
    cuda_version = cached_cuda_version()
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/virtual_packages/cuda.py", line 61, in cached_cuda_version
    return cuda_version()
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/site-packages/conda/plugins/virtual_packages/cuda.py", line 49, in cuda_version
    detector.kill()  # requires Python 3.7+
  File "/home/sgimeno/.conda/envs/link-recommendation-env/lib/python3.10/multiprocessing/process.py", line 140, in kill
    self._popen.kill()
AttributeError: 'NoneType' object has no attribute 'kill'

@Urbanecm_WMF discovered that wrapping the two spark jobs into if __name__ == "__main__" prevents this issue from happening.

Details

Related Changes in Gerrit:

Event Timeline

Urbanecm_WMF renamed this task from Training mwaddlink causes an xxx error to Training mwaddlink causes an AttributeError: 'NoneType' object has no attribute 'kill' error.Jun 10 2025, 4:22 PM

Change #1153637 had a related patch set uploaded (by Urbanecm; author: Sergio Gimeno):

[research/mwaddlink@main] run-pipline: improve script logging

https://gerrit.wikimedia.org/r/1153637

Urbanecm_WMF moved this task from Incoming to QA on the Growth-Team (Current Sprint) board.
Urbanecm_WMF changed the subtype of this task from "Task" to "Bug Report".

Change #1153637 merged by jenkins-bot:

[research/mwaddlink@main] run-pipline: improve script logging

https://gerrit.wikimedia.org/r/1153637