정확히는, kss 코드가 있으면 이상하게 kss가 2번 실행됩니다.
kss가 처음 실행 되는 순간 뭔가를 진행하다가 파일을 처음부터 다시 실행하고, 이후 2번째 kss 실행에서 크래시가 일어납니다.
만약 kss 부분 이외의 코드가 짧다면 kss의 2번째 실행이 진행되던 도중에 파일이 처음부터 실행되고 크래시가 일어납니다.
다른 분께서 적으신, close된 이슈를 보니 멀티프로세싱의 문제라고 하셨습니다.
그런데 제가 멀티프로세싱이 일어날 이유가 없는 기본 코드를 실행했음에도 두 번 실행됩니다.
즉, kss 내부 코드 문제로 멀티프로세싱이 되었다고 생각합니다.
파이참 기본 설정은 멀티프로세싱이 아닌 것으로 알고 있습니다.
테스트 코드 1입니다.
[Korean Sentence Splitter]: Initializing Pynori...
[Korean Sentence Splitter]: Initializing Pynori...
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\USER\PycharmProjects\kiwiTest\main.py", line 4, in
kss.split_sentences('')
File "C:\Users\USER\PycharmProjects\kiwiTest\venv\lib\site-packages\kss\kss.py", line 122, in split_sentences
preprocessed_list = list(pool.map(build_preprocessed_list, _text))
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 761, in map
results = super().map(partial(_process_chunk, fn),
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 610, in map
fs = [self.submit(fn, *args) for args in zip(*iterables)]
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 610, in
fs = [self.submit(fn, *args) for args in zip(*iterables)]
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 732, in submit
self._adjust_process_count()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 692, in _adjust_process_count
self._spawn_process()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 709, in _spawn_process
p.start()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\context.py", line 336, in _Popen
return Popen(process_obj)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\popen_spawn_win32.py", line 45, in init
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\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.
Traceback (most recent call last):
File "C:\Users\USER\PycharmProjects\kiwiTest\main.py", line 4, in
kss.split_sentences('')
File "C:\Users\USER\PycharmProjects\kiwiTest\venv\lib\site-packages\kss\kss.py", line 122, in split_sentences
preprocessed_list = list(pool.map(build_preprocessed_list, _text))
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 570, in _chain_from_iterable_of_lists
for element in iterable:
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 621, in result_iterator
yield _result_or_cancel(fs.pop())
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 319, in _result_or_cancel
return fut.result(timeout)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 458, in result
return self.__get_result()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 403, in __get_result
raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
Process finished with exit code 1
결과 1입니다.
테스트 코드 2입니다.
C:\Users\USER\PycharmProjects\kiwiTest\venv\Scripts\python.exe C:/Users/USER/PycharmProjects/kiwiTest/main.py
[Korean Sentence Splitter]: Initializing Pynori...
a
[Korean Sentence Splitter]: Initializing Pynori...
a
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\USER\PycharmProjects\kiwiTest\main.py", line 5, in
kss.split_sentences('')
File "C:\Users\USER\PycharmProjects\kiwiTest\venv\lib\site-packages\kss\kss.py", line 122, in split_sentences
preprocessed_list = list(pool.map(build_preprocessed_list, _text))
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 761, in map
results = super().map(partial(_process_chunk, fn),
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 610, in map
fs = [self.submit(fn, *args) for args in zip(*iterables)]
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 610, in
fs = [self.submit(fn, *args) for args in zip(*iterables)]
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 732, in submit
self._adjust_process_count()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 692, in _adjust_process_count
self._spawn_process()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 709, in _spawn_process
p.start()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\context.py", line 336, in _Popen
return Popen(process_obj)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\popen_spawn_win32.py", line 45, in init
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\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.
Traceback (most recent call last):
File "C:\Users\USER\PycharmProjects\kiwiTest\main.py", line 5, in
kss.split_sentences('')
File "C:\Users\USER\PycharmProjects\kiwiTest\venv\lib\site-packages\kss\kss.py", line 122, in split_sentences
preprocessed_list = list(pool.map(build_preprocessed_list, _text))
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\process.py", line 570, in _chain_from_iterable_of_lists
for element in iterable:
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 621, in result_iterator
yield _result_or_cancel(fs.pop())
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 319, in _result_or_cancel
return fut.result(timeout)
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 458, in result
return self.__get_result()
File "C:\Users\USER\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 403, in __get_result
raise self._exception
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
Process finished with exit code 1
결과 2입니다.
제가 파이참에 대해서 잘못 알고 있는 것일 수도 있지만 확실히 뭔가 이상하다고 생각합니다.