diff --git a/doit/doit_cmd.py b/doit/doit_cmd.py
index e1be34d..ce6ed15 100644
--- a/doit/doit_cmd.py
+++ b/doit/doit_cmd.py
@@ -32,6 +32,8 @@ def reset_vars():
     _CMDLINE_VARS = {}
 
 def get_var(name, default=None):
+    if _CMDLINE_VARS is None:
+        return None
     return _CMDLINE_VARS.get(name, default)
 
 def set_var(name, value):

'get_var' fails while the multiprocess execution if any task uses delayed creation.
@schettino72 , hey! :)

So, i found strange behaviour while trying to implement some stuff.

```.py
#! /usr/bin/doit -f
# -*- coding: utf-8 -*-

from doit import get_var
from doit import create_after

get_var( 'A', None )


def task_foo() :
  return {
    'actions': [ 'echo foo' ],
    'task_dep': [ 'bar' ],
  }
  
@create_after( executed = 'baz' )
def task_bar() :
  for i in range( 10 ) :
    yield {
      'name': 'bar_{}'.format( i ),
      'actions': [ 'echo bar_{}'.format( i ) ]
    }
    
def task_baz() :
  for i in range( 10 ) :
    yield {
      'name': 'baz_{}'.format( i ),
      'actions': [ 'echo baz_{}'.format( i ) ]
    }
```

This code works fine while being executed in single-process mode. But it fails in multi process mode.

```
/root>GetVar.py -n 2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/py3.4/lib/multiprocessing/spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
  File "/py3.4/lib/multiprocessing/spawn.py", line 116, in _main
    self = pickle.load(from_parent)
  File "/root/GetVar.py", line 7, in <module>
    get_var( 'A', None )
  File "/py3.4/lib/site-packages/doit/doit_cmd.py", line 35, in get_var
    return _CMDLINE_VARS.get(name, default)
AttributeError: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/py3.4/lib/multiprocessing/spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
  File "/py3.4/lib/multiprocessing/spawn.py", line 116, in _main
    self = pickle.load(from_parent)
  File "/root/GetVar.py", line 7, in <module>
    get_var( 'A', None )
  File "/py3.4/lib/site-packages/doit/doit_cmd.py", line 35, in get_var
    return _CMDLINE_VARS.get(name, default)
AttributeError: 'NoneType' object has no attribute 'get'
```

But if i remove the `create_after` decorator, all became works fine even in multi process mode. So, i found it ambiguous. I had seen no notifications in docs about such behaviour.

Can you confirm this is the doit error or not?
Currently i use the last (0.30.0) version of doit.
diff --git a/tests/test_doit_cmd.py b/tests/test_doit_cmd.py
index 90d51a2..84c740a 100644
--- a/tests/test_doit_cmd.py
+++ b/tests/test_doit_cmd.py
@@ -45,6 +45,17 @@ class TestRun(object):
         cmd_main(['x=1', 'y=abc'])
         assert '1' == doit_cmd.get_var('x')
         assert 'abc' == doit_cmd.get_var('y')
+        assert None is doit_cmd.get_var('z')
+
+    def test_cmdline_novars(self, monkeypatch):
+        mock_run = Mock()
+        monkeypatch.setattr(Run, "execute", mock_run)
+        cmd_main(['x=1'])
+
+        # Simulate the variable below not being initialized by a subprocess on
+        # Windows. See https://github.com/pydoit/doit/issues/164.
+        doit_cmd._CMDLINE_VARS = None
+        assert None is doit_cmd.get_var('x')
 
     def test_cmdline_vars_not_opts(self, monkeypatch):
         mock_run = Mock()

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
dev_requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
cloudpickle==3.1.1
configclass==0.2.0
coverage==7.8.0
-e git+https://github.com/pydoit/doit.git@62335b05473193303d6ecb5524d65bf1a5a50d7e#egg=doit
doit-py==0.5.0
exceptiongroup==1.2.2
importlib_metadata==8.6.1
iniconfig==2.1.0
mergedict==1.0.0
packaging==24.2
pluggy==1.5.0
pyflakes==3.3.1
pyinotify==0.9.6
pytest==8.3.5
pytest-ignore-flaky==2.2.1
tomli==2.2.1
zipp==3.21.0

name: doit
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cloudpickle==3.1.1
      - configclass==0.2.0
      - coverage==7.8.0
      - doit-py==0.5.0
      - exceptiongroup==1.2.2
      - importlib-metadata==8.6.1
      - iniconfig==2.1.0
      - mergedict==1.0.0
      - packaging==24.2
      - pluggy==1.5.0
      - pyflakes==3.3.1
      - pyinotify==0.9.6
      - pytest==8.3.5
      - pytest-ignore-flaky==2.2.1
      - tomli==2.2.1
      - zipp==3.21.0
prefix: /opt/conda/envs/doit

tests/test_doit_cmd.py::TestRun::test_cmdline_novars
tests/test_doit_cmd.py::TestRun::test_version tests/test_doit_cmd.py::TestRun::test_usage tests/test_doit_cmd.py::TestRun::test_run_is_default tests/test_doit_cmd.py::TestRun::test_run_other_subcommand tests/test_doit_cmd.py::TestRun::test_cmdline_vars tests/test_doit_cmd.py::TestRun::test_cmdline_vars_not_opts tests/test_doit_cmd.py::TestRun::test_task_loader_has_cmd_list tests/test_doit_cmd.py::TestErrors::test_interrupt tests/test_doit_cmd.py::TestErrors::test_user_error tests/test_doit_cmd.py::TestErrors::test_internal_error tests/test_doit_cmd.py::TestConfig::test_no_ini_config_file tests/test_doit_cmd.py::TestConfig::test_load_plugins_command tests/test_doit_cmd.py::TestConfig::test_merge_api_ini_config tests/test_doit_cmd.py::TestConfig::test_execute_command_plugin
doit/doit_cmd.py
doit/doit_cmd.py