jina-ai / serve

☁️ Build multimodal AI applications with cloud-native stack
https://jina.ai/serve
Apache License 2.0
21.13k stars 2.22k forks source link

Docker executors do not work on windows. #4850

Closed amazingvince closed 2 years ago

amazingvince commented 2 years ago

Describe the bug multiprocessor blows up when docker executor is called. This can be from hub or built locally. I tried follow documentation about build custom docker executor. I can post a full stack trace but its huge. I tried to follow this exactly: https://docs.jina.ai/fundamentals/executor/containerize-executor/ Also tried using a few different executors from jina hub and saw similar stack traces. There is a deprecation warning as well: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)

Describe how you solve it


Environment

Screenshots

JoanFM commented 2 years ago

Hey @amazingvince,

it would be very helpful to provide the complete stack trace.

amazingvince commented 2 years ago
venv) PS D:\code\jina_demo\> python .\test.py
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:53)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:53)
⠼ Waiting executor0 gateway ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/2 0:00:02DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:53)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:53)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:53)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:52)
DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. (raised from D:\code\jina_demo\venv\lib\site-packages\docker\utils\utils.py:53)
⠏ Waiting executor0 gateway ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/2 0:00:03╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ <string>:1 in <module>                                                                           │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:116 in spawn_main                                       │
│                                                                                                  │
│   113 │   │   resource_tracker._resource_tracker._fd = tracker_fd                                │
│   114 │   │   fd = pipe_handle                                                                   │
│   115 │   │   parent_sentinel = os.dup(pipe_handle)                                              │
│ ❱ 116 │   exitcode = _main(fd, parent_sentinel)                                                  │
│   117 │   sys.exit(exitcode)                                                                     │
│   118                                                                                            │
│   119                                                                                            │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:125 in _main                                            │
│                                                                                                  │
│   122 │   │   process.current_process()._inheriting = True                                       │
│   123 │   │   try:                                                                               │
│   124 │   │   │   preparation_data = reduction.pickle.load(from_parent)                          │
│ ❱ 125 │   │   │   prepare(preparation_data)                                                      │
│   126 │   │   │   self = reduction.pickle.load(from_parent)                                      │
│   127 │   │   finally:                                                                           │
│   128 │   │   │   del process.current_process()._inheriting                                      │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:236 in prepare                                          │
│                                                                                                  │
│   233 │   if 'init_main_from_name' in data:                                                      │
│   234 │   │   _fixup_main_from_name(data['init_main_from_name'])                                 │
│   235 │   elif 'init_main_from_path' in data:                                                    │
│ ❱ 236 │   │   _fixup_main_from_path(data['init_main_from_path'])                                 │
│   237                                                                                            │
│   238 # Multiprocessing module helpers to fix up the main module in                              │
│   239 # spawned subprocesses                                                                     │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:287 in _fixup_main_from_path                            │
│                                                                                                  │
│   284 │   # non-main code that needs to be executed                                              │
│   285 │   old_main_modules.append(current_main)                                                  │
│   286 │   main_module = types.ModuleType("__mp_main__")                                          │
│ ❱ 287 │   main_content = runpy.run_path(main_path,                                               │
│   288 │   │   │   │   │   │   │   │     run_name="__mp_main__")                                  │
│   289 │   main_module.__dict__.update(main_content)                                              │
│   290 │   sys.modules['__main__'] = sys.modules['__mp_main__'] = main_module                     │
│                                                                                                  │
│ C:\Python39\lib\runpy.py:268 in run_path                                                         │
│                                                                                                  │
│   265 │   │   # Not a valid sys.path entry, so run the code directly                             │
│   266 │   │   # execfile() doesn't help as we want to allow compiled files                       │
│   267 │   │   code, fname = _get_code_from_file(run_name, path_name)                             │
│ ❱ 268 │   │   return _run_module_code(code, init_globals, run_name,                              │
│   269 │   │   │   │   │   │   │   │   pkg_name=pkg_name, script_name=fname)                      │
│   270 │   else:                                                                                  │
│   271 │   │   # Finder is defined for path, so add it to                                         │
│                                                                                                  │
│ C:\Python39\lib\runpy.py:97 in _run_module_code                                                  │
│                                                                                                  │
│    94 │   fname = script_name if mod_spec is None else mod_spec.origin                           │
│    95 │   with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):                      │
│    96 │   │   mod_globals = temp_module.module.__dict__                                          │
│ ❱  97 │   │   _run_code(code, mod_globals, init_globals,                                         │
│    98 │   │   │   │     mod_name, mod_spec, pkg_name, script_name)                               │
│    99 │   # Copy the globals of the temporary module, as they                                    │
│   100 │   # may be cleared when the temporary module goes away                                   │
│                                                                                                  │
│ C:\Python39\lib\runpy.py:87 in _run_code                                                         │
│                                                                                                  │
│    84 │   │   │   │   │      __loader__ = loader,                                                │
│    85 │   │   │   │   │      __package__ = pkg_name,                                             │
│    86 │   │   │   │   │      __spec__ = mod_spec)                                                │
│ ❱  87 │   exec(code, run_globals)                                                                │
│    88 │   return run_globals                                                                     │
│    89                                                                                            │
│    90 def _run_module_code(code, init_globals=None,                                              │
│                                                                                                  │
│ D:\code\jina_demo\email-search\test.py:6 in <module>                                             │
│                                                                                                  │
│    3                                                                                             │
│    4 f = Flow().add(uses='docker://my_containerized_executor')                                   │
│    5                                                                                             │
│ ❱  6 with f:                                                                                     │
│    7 │   returned_docs = f.post(on='/', inputs=DocumentArray([Document()]))                      │
│    8                                                                                             │
│    9 for doc in returned_docs:                                                                   │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\flow\base.py:1107 in __enter__         │
│                                                                                                  │
│   1104 │                                                                                         │
│   1105 │   def __enter__(self):                                                                  │
│   1106 │   │   with CatchAllCleanupContextManager(self):                                         │
│ ❱ 1107 │   │   │   return self.start()                                                           │
│   1108 │                                                                                         │
│   1109 │   def __exit__(self, exc_type, exc_val, exc_tb):                                        │
│   1110 │   │   if hasattr(self, '_stop_event'):                                                  │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\flow\base.py:1160 in start             │
│                                                                                                  │
│   1157 │   │                                                                                     │
│   1158 │   │   for k, v in self:                                                                 │
│   1159 │   │   │   if not v.external:                                                            │
│ ❱ 1160 │   │   │   │   self.enter_context(v)                                                     │
│   1161 │   │                                                                                     │
│   1162 │   │   self._wait_until_all_ready()                                                      │
│   1163                                                                                           │
│                                                                                                  │
│ C:\Python39\lib\contextlib.py:429 in enter_context                                               │
│                                                                                                  │
│   426 │   │   # statement.                                                                       │
│   427 │   │   _cm_type = type(cm)                                                                │
│   428 │   │   _exit = _cm_type.__exit__                                                          │
│ ❱ 429 │   │   result = _cm_type.__enter__(cm)                                                    │
│   430 │   │   self._push_cm_exit(cm, _exit)                                                      │
│   431 │   │   return result                                                                      │
│   432                                                                                            │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\deployments\__init__.py:105 in         │
│ __enter__                                                                                        │
│                                                                                                  │
│   102 │                                                                                          │
│   103 │   def __enter__(self) -> 'BaseDeployment':                                               │
│   104 │   │   with CatchAllCleanupContextManager(self):                                          │
│ ❱ 105 │   │   │   return self.start()                                                            │
│   106 │                                                                                          │
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│   107 │   @staticmethod                                                                          │
│ <string>:1 in <module>                                                                           │
│   108 │   def _copy_to_head_args(args: Namespace) -> Namespace:                                  │
│                                                                                                  │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:116 in spawn_main                                       │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\deployments\__init__.py:542 in start   │
│                                                                                                  │
│                                                                                                  │
│   113 │   │   resource_tracker._resource_tracker._fd = tracker_fd                                │
│   539 │   │   │   │   self.pod_args['pods'][shard_id],                                           │
│   114 │   │   fd = pipe_handle                                                                   │
│   540 │   │   │   │   self.head_pod,                                                             │
│   115 │   │   parent_sentinel = os.dup(pipe_handle)                                              │
│   541 │   │   │   )                                                                              │
│ ❱ 116 │   exitcode = _main(fd, parent_sentinel)                                                  │
│ ❱ 542 │   │   │   self.enter_context(self.shards[shard_id])                                      │
│   117 │   sys.exit(exitcode)                                                                     │
│   543 │   │                                                                                      │
│   118                                                                                            │
│   544 │   │   if not getattr(self.args, 'noblock_on_start', False):                              │
│   119                                                                                            │
│   545 │   │   │   self.activate()                                                                │
│                                                                                                  │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:125 in _main                                            │
│ C:\Python39\lib\contextlib.py:429 in enter_context                                               │
│                                                                                                  │
│                                                                                                  │
│   122 │   │   process.current_process()._inheriting = True                                       │
│   426 │   │   # statement.                                                                       │
│   123 │   │   try:                                                                               │
│   124 │   │   │   preparation_data = reduction.pickle.load(from_parent)                          │
│   427 │   │   _cm_type = type(cm)                                                                │
│   428 │   │   _exit = _cm_type.__exit__                                                          │
│ ❱ 125 │   │   │   prepare(preparation_data)                                                      │
│ ❱ 429 │   │   result = _cm_type.__enter__(cm)                                                    │
│   126 │   │   │   self = reduction.pickle.load(from_parent)                                      │
│   430 │   │   self._push_cm_exit(cm, _exit)                                                      │
│   127 │   │   finally:                                                                           │
│   128 │   │   │   del process.current_process()._inheriting                                      │
│   431 │   │   return result                                                                      │
│                                                                                                  │
│   432                                                                                            │
│ C:\Python39\lib\multiprocessing\spawn.py:236 in prepare                                          │
│                                                                                                  │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\deployments\__init__.py:216 in         │
│   233 │   if 'init_main_from_name' in data:                                                      │
│ __enter__                                                                                        │
│   234 │   │   _fixup_main_from_name(data['init_main_from_name'])                                 │
│                                                                                                  │
│   235 │   elif 'init_main_from_path' in data:                                                    │
│   213 │   │   │   for _args in self.args:                                                        │
│ ❱ 236 │   │   _fixup_main_from_path(data['init_main_from_path'])                                 │
│   214 │   │   │   │   if getattr(self.deployment_args, 'noblock_on_start', False):               │
│   237                                                                                            │
│   215 │   │   │   │   │   _args.noblock_on_start = True                                          │
│   238 # Multiprocessing module helpers to fix up the main module in                              │
│ ❱ 216 │   │   │   │   self._pods.append(PodFactory.build_pod(_args).start())                     │
│   239 # spawned subprocesses                                                                     │
│   217 │   │   │   return self                                                                    │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:287 in _fixup_main_from_path                            │
│   218 │   │                                                                                      │
│                                                                                                  │
│   219 │   │   def __exit__(self, exc_type, exc_val, exc_tb):                                     │
│   284 │   # non-main code that needs to be executed                                              │
│   285 │   old_main_modules.append(current_main)                                                  │
│   286 │   main_module = types.ModuleType("__mp_main__")                                          │
│                                                                                                  │
│ ❱ 287 │   main_content = runpy.run_path(main_path,                                               │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\pods\container.py:385 in start         │
│   288 │   │   │   │   │   │   │   │     run_name="__mp_main__")                                  │
│   289 │   main_module.__dict__.update(main_content)                                              │
│                                                                                                  │
│   290 │   sys.modules['__main__'] = sys.modules['__mp_main__'] = main_module                     │
│   382 │   │   │   },                                                                             │
│                                                                                                  │
│   383 │   │   │   daemon=True,                                                                   │
│ C:\Python39\lib\runpy.py:268 in run_path                                                         │
│   384 │   │   )                                                                                  │
│                                                                                                  │
│ ❱ 385 │   │   self.worker.start()                                                                │
│   265 │   │   # Not a valid sys.path entry, so run the code directly                             │
│   266 │   │   # execfile() doesn't help as we want to allow compiled files                       │
│   386 │   │   if not self.args.noblock_on_start:                                                 │
│   267 │   │   code, fname = _get_code_from_file(run_name, path_name)                             │
│ ❱ 268 │   │   return _run_module_code(code, init_globals, run_name,                              │
│   387 │   │   │   self.wait_start_success()                                                      │
│   269 │   │   │   │   │   │   │   │   pkg_name=pkg_name, script_name=fname)                      │
│   270 │   else:                                                                                  │
│   388 │   │   return self                                                                        │
│   271 │   │   # Finder is defined for path, so add it to                                         │
│                                                                                                  │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\process.py:121 in start                                          │
│ C:\Python39\lib\runpy.py:97 in _run_module_code                                                  │
│                                                                                                  │
│                                                                                                  │
│   118 │   │   assert not _current_process._config.get('daemon'), \                               │
│    94 │   fname = script_name if mod_spec is None else mod_spec.origin                           │
│   119 │   │   │      'daemonic processes are not allowed to have children'                       │
│    95 │   with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):                      │
│   120 │   │   _cleanup()                                                                         │
│    96 │   │   mod_globals = temp_module.module.__dict__                                          │
│ ❱ 121 │   │   self._popen = self._Popen(self)                                                    │
│ ❱  97 │   │   _run_code(code, mod_globals, init_globals,                                         │
│   122 │   │   self._sentinel = self._popen.sentinel                                              │
│    98 │   │   │   │     mod_name, mod_spec, pkg_name, script_name)                               │
│   123 │   │   # Avoid a refcycle if the target function holds an indirect                        │
│    99 │   # Copy the globals of the temporary module, as they                                    │
│   124 │   │   # reference to the process object (see bpo-30775)                                  │
│   100 │   # may be cleared when the temporary module goes away                                   │
│                                                                                                  │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\context.py:224 in _Popen                                         │
│ C:\Python39\lib\runpy.py:87 in _run_code                                                         │
│                                                                                                  │
│                                                                                                  │
│   221 │   _start_method = None                                                                   │
│    84 │   │   │   │   │      __loader__ = loader,                                                │
│   222 │   @staticmethod                                                                          │
│    85 │   │   │   │   │      __package__ = pkg_name,                                             │
│   223 │   def _Popen(process_obj):                                                               │
│    86 │   │   │   │   │      __spec__ = mod_spec)                                                │
│ ❱ 224 │   │   return _default_context.get_context().Process._Popen(process_obj)                  │
│ ❱  87 │   exec(code, run_globals)                                                                │
│   225                                                                                            │
│    88 │   return run_globals                                                                     │
│   226 class DefaultContext(BaseContext):                                                         │
│    89                                                                                            │
│   227 │   Process = Process                                                                      │
│    90 def _run_module_code(code, init_globals=None,                                              │
│                                                                                                  │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\context.py:327 in _Popen                                         │
│ D:\code\jina_demo\email-search\test.py:6 in <module>                                             │
│                                                                                                  │
│                                                                                                  │
│   324 │   │   @staticmethod                                                                      │
│    3                                                                                             │
│   325 │   │   def _Popen(process_obj):                                                           │
│    4 f = Flow().add(uses='docker://my_containerized_executor')                                   │
│   326 │   │   │   from .popen_spawn_win32 import Popen                                           │
│    5                                                                                             │
│ ❱ 327 │   │   │   return Popen(process_obj)                                                      │
│ ❱  6 with f:                                                                                     │
│   328 │                                                                                          │
│    7 │   returned_docs = f.post(on='/', inputs=DocumentArray([Document()]))                      │
│   329 │   class SpawnContext(BaseContext):                                                       │
│    8                                                                                             │
│    9 for doc in returned_docs:                                                                   │
│   330 │   │   _name = 'spawn'                                                                    │
│                                                                                                  │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\flow\base.py:1107 in __enter__         │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\popen_spawn_win32.py:45 in __init__                              │
│   1104 │                                                                                         │
│                                                                                                  │
│   1105 │   def __enter__(self):                                                                  │
│    42 │   method = 'spawn'                                                                       │
│   1106 │   │   with CatchAllCleanupContextManager(self):                                         │
│    43 │                                                                                          │
│ ❱ 1107 │   │   │   return self.start()                                                           │
│   1108 │                                                                                         │
│    44 │   def __init__(self, process_obj):                                                       │
│   1109 │   def __exit__(self, exc_type, exc_val, exc_tb):                                        │
│ ❱  45 │   │   prep_data = spawn.get_preparation_data(process_obj._name)                          │
│   1110 │   │   if hasattr(self, '_stop_event'):                                                  │
│    46 │   │                                                                                      │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\flow\base.py:1160 in start             │
│    47 │   │   # read end of pipe will be duplicated by the child process                         │
│                                                                                                  │
│    48 │   │   # -- see spawn_main() in spawn.py.                                                 │
│   1157 │   │                                                                                     │
│                                                                                                  │
│   1158 │   │   for k, v in self:                                                                 │
│ C:\Python39\lib\multiprocessing\spawn.py:154 in get_preparation_data                             │
│   1159 │   │   │   if not v.external:                                                            │
│                                                                                                  │
│ ❱ 1160 │   │   │   │   self.enter_context(v)                                                     │
│   151 │   '''                                                                                    │
│   1161 │   │                                                                                     │
│   1162 │   │   self._wait_until_all_ready()                                                      │
│   152 │   Return info about parent needed by child to unpickle process object                    │
│   1163                                                                                           │
│   153 │   '''                                                                                    │
│                                                                                                  │
│ C:\Python39\lib\contextlib.py:429 in enter_context                                               │
│ ❱ 154 │   _check_not_importing_main()                                                            │
│                                                                                                  │
│   155 │   d = dict(                                                                              │
│   426 │   │   # statement.                                                                       │
│   156 │   │   log_to_stderr=util._log_to_stderr,                                                 │
│   427 │   │   _cm_type = type(cm)                                                                │
│   157 │   │   authkey=process.current_process().authkey,                                         │
│   428 │   │   _exit = _cm_type.__exit__                                                          │
│                                                                                                  │
│ ❱ 429 │   │   result = _cm_type.__enter__(cm)                                                    │
│ C:\Python39\lib\multiprocessing\spawn.py:134 in _check_not_importing_main                        │
│   430 │   │   self._push_cm_exit(cm, _exit)                                                      │
│                                                                                                  │
│   431 │   │   return result                                                                      │
│   131                                                                                            │
│   432                                                                                            │
│   132 def _check_not_importing_main():                                                           │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\deployments\__init__.py:105 in         │
│ __enter__                                                                                        │
│                                                                                                  │
│   102 │                                                                                          │
│   103 │   def __enter__(self) -> 'BaseDeployment':                                               │
│   104 │   │   with CatchAllCleanupContextManager(self):                                          │
│ ❱ 105 │   │   │   return self.start()                                                            │
│   106 │                                                                                          │
│   133 │   if getattr(process.current_process(), '_inheriting', False):                           │
│   107 │   @staticmethod                                                                          │
│ ❱ 134 │   │   raise RuntimeError('''                                                             │
│   108 │   def _copy_to_head_args(args: Namespace) -> Namespace:                                  │
│   135 │   │   An attempt has been made to start a new process before the                         │
│                                                                                                  │
│   136 │   │   current process has finished its bootstrapping phase.                              │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\deployments\__init__.py:542 in start   │
│   137                                                                                            │
│                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
│   539 │   │   │   │   self.pod_args['pods'][shard_id],                                           │
RuntimeError: 
│   540 │   │   │   │   self.head_pod,                                                             │
        An attempt has been made to start a new process before the
│   541 │   │   │   )                                                                              │
        current process has finished its bootstrapping phase.
│ ❱ 542 │   │   │   self.enter_context(self.shards[shard_id])                                      │

│   543 │   │                                                                                      │
        This probably means that you are not using fork to start your
│   544 │   │   if not getattr(self.args, 'noblock_on_start', False):                              │
        child processes and you have forgotten to use the proper idiom
│   545 │   │   │   self.activate()                                                                │
        in the main module:
│                                                                                                  │
│ C:\Python39\lib\contextlib.py:429 in enter_context                                               │

│                                                                                                  │
            if __name__ == '__main__':
                freeze_support()
│   426 │   │   # statement.                                                                       │
                ...

│   427 │   │   _cm_type = type(cm)                                                                │
        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
│   428 │   │   _exit = _cm_type.__exit__                                                          │
│ ❱ 429 │   │   result = _cm_type.__enter__(cm)                                                    │
│   430 │   │   self._push_cm_exit(cm, _exit)                                                      │
│   431 │   │   return result                                                                      │
│   432                                                                                            │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\deployments\__init__.py:216 in         │
│ __enter__                                                                                        │
│                                                                                                  │
│   213 │   │   │   for _args in self.args:                                                        │
│   214 │   │   │   │   if getattr(self.deployment_args, 'noblock_on_start', False):               │
│   215 │   │   │   │   │   _args.noblock_on_start = True                                          │
│ ❱ 216 │   │   │   │   self._pods.append(PodFactory.build_pod(_args).start())                     │
│   217 │   │   │   return self                                                                    │
│   218 │   │                                                                                      │
│   219 │   │   def __exit__(self, exc_type, exc_val, exc_tb):                                     │
│                                                                                                  │
│ D:\code\jina_demo\venv\lib\site-packages\jina\orchestrate\pods\container.py:385 in start         │
│                                                                                                  │
│   382 │   │   │   },                                                                             │
│   383 │   │   │   daemon=True,                                                                   │
│   384 │   │   )                                                                                  │
│ ❱ 385 │   │   self.worker.start()                                                                │
│   386 │   │   if not self.args.noblock_on_start:                                                 │
│   387 │   │   │   self.wait_start_success()                                                      │
│   388 │   │   return self                                                                        │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\process.py:121 in start                                          │
│                                                                                                  │
│   118 │   │   assert not _current_process._config.get('daemon'), \                               │
│   119 │   │   │      'daemonic processes are not allowed to have children'                       │
│   120 │   │   _cleanup()                                                                         │
│ ❱ 121 │   │   self._popen = self._Popen(self)                                                    │
│   122 │   │   self._sentinel = self._popen.sentinel                                              │
│   123 │   │   # Avoid a refcycle if the target function holds an indirect                        │
│   124 │   │   # reference to the process object (see bpo-30775)                                  │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\context.py:224 in _Popen                                         │
│                                                                                                  │
│   221 │   _start_method = None                                                                   │
│   222 │   @staticmethod                                                                          │
│   223 │   def _Popen(process_obj):                                                               │
│ ❱ 224 │   │   return _default_context.get_context().Process._Popen(process_obj)                  │
│   225                                                                                            │
│   226 class DefaultContext(BaseContext):                                                         │
│   227 │   Process = Process                                                                      │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\context.py:327 in _Popen                                         │
│                                                                                                  │
│   324 │   │   @staticmethod                                                                      │
│   325 │   │   def _Popen(process_obj):                                                           │
│   326 │   │   │   from .popen_spawn_win32 import Popen                                           │
│ ❱ 327 │   │   │   return Popen(process_obj)                                                      │
│   328 │                                                                                          │
│   329 │   class SpawnContext(BaseContext):                                                       │
│   330 │   │   _name = 'spawn'                                                                    │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\popen_spawn_win32.py:45 in __init__                              │
│                                                                                                  │
│    42 │   method = 'spawn'                                                                       │
│    43 │                                                                                          │
│    44 │   def __init__(self, process_obj):                                                       │
│ ❱  45 │   │   prep_data = spawn.get_preparation_data(process_obj._name)                          │
│    46 │   │                                                                                      │
│    47 │   │   # read end of pipe will be duplicated by the child process                         │
│    48 │   │   # -- see spawn_main() in spawn.py.                                                 │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:154 in get_preparation_data                             │
│                                                                                                  │
│   151 │   '''                                                                                    │
│   152 │   Return info about parent needed by child to unpickle process object                    │
│   153 │   '''                                                                                    │
│ ❱ 154 │   _check_not_importing_main()                                                            │
│   155 │   d = dict(                                                                              │
│   156 │   │   log_to_stderr=util._log_to_stderr,                                                 │
│   157 │   │   authkey=process.current_process().authkey,                                         │
│                                                                                                  │
│ C:\Python39\lib\multiprocessing\spawn.py:134 in _check_not_importing_main                        │
│                                                                                                  │
│   131                                                                                            │
│   132 def _check_not_importing_main():                                                           │
│   133 │   if getattr(process.current_process(), '_inheriting', False):                           │
│ ❱ 134 │   │   raise RuntimeError('''                                                             │
│   135 │   │   An attempt has been made to start a new process before the                         │
│   136 │   │   current process has finished its bootstrapping phase.                              │
│   137                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
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.
JoanFM commented 2 years ago

Have u checked this documentation and the following issues about spawn multiprocessing?

https://docs.jina.ai/get-started/install/windows/

JoanFM commented 2 years ago

Basically, I think you should make sure to put your main method under:

if __name__ == '__main__':
    # entrypoint code
JoanFM commented 2 years ago

Hey @amazingvince, Did this solution work for u?

amazingvince commented 2 years ago

I never was able to get it to run in windows. I just spun up a ubuntu VM and it worked like a charm.