Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
7d6694b1
Commit
7d6694b1
authored
Jul 27, 2023
by
jyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mutil thread
parent
37f5bb3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
indexing_runner.py
api/core/indexing_runner.py
+6
-0
No files found.
api/core/indexing_runner.py
View file @
7d6694b1
...
...
@@ -10,6 +10,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
from
typing
import
Optional
,
List
,
cast
import
openai
from
billiard.pool
import
Pool
from
flask
import
current_app
,
Flask
from
flask_login
import
current_user
from
langchain.embeddings
import
OpenAIEmbeddings
...
...
@@ -538,6 +539,11 @@ class IndexingRunner:
# document_format_thread.start()
# for thread in threads:
# thread.join()
# with Pool(5) as pool:
# for doc in documents:
# result = pool.apply_async(format_document, kwds={'flask_app': current_app._get_current_object(), 'document_node': doc, 'split_documents': split_documents})
# if result.ready():
# split_documents.extend(result.get())
with
ThreadPoolExecutor
(
max_workers
=
10
)
as
executor
:
future_to_doc
=
{
executor
.
submit
(
format_document
,
current_app
.
_get_current_object
(),
doc
):
doc
for
doc
in
documents
}
for
future
in
concurrent
.
futures
.
as_completed
(
future_to_doc
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment