Skip to content

Commit e874b37

Browse files
committed
fix: use forkserver as process start method
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 309ab2b commit e874b37

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
44
# SPDX-License-Identifier: AGPL-3.0-or-later
55
#
6+
67
import logging
78
from os import cpu_count, getenv
89

@@ -44,6 +45,18 @@ def _setup_log_levels(debug: bool):
4445

4546

4647
if __name__ == '__main__':
48+
import multiprocessing as mp
49+
50+
# do forks from a clean process that doesn't have any threads or locks
51+
mp.set_start_method('forkserver')
52+
mp.set_forkserver_preload([
53+
'langchain',
54+
'sqlalchemy',
55+
'numpy',
56+
'context_chat_backend.chain.ingest.injest',
57+
'context_chat_backend.vectordb.pgvector',
58+
])
59+
4760
logging_config = get_logging_config(LOGGER_CONFIG_NAME)
4861
setup_logging(logging_config)
4962
app_config: TConfig = app.extra['CONFIG']

0 commit comments

Comments
 (0)