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
9816e13f
Commit
9816e13f
authored
Jul 28, 2023
by
jyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mutil thread
parent
6a1a0a6c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
test_task.py
api/tasks/test_task.py
+43
-0
No files found.
api/tasks/test_task.py
0 → 100644
View file @
9816e13f
import
threading
from
time
import
sleep
,
ctime
from
typing
import
List
from
celery
import
shared_task
@
shared_task
def
test_task
():
"""
Clean dataset when dataset deleted.
Usage: test_task.delay(dataset_id, tenant_id, indexing_technique, index_struct)
"""
print
(
'---开始---:
%
s'
%
ctime
())
def
smoke
(
count
:
List
):
for
i
in
range
(
3
):
print
(
"smoke...
%
d"
%
i
)
count
.
append
(
"smoke...
%
d"
%
i
)
sleep
(
1
)
def
drunk
(
count
:
List
):
for
i
in
range
(
3
):
print
(
"drink...
%
d"
%
i
)
count
.
append
(
"drink...
%
d"
%
i
)
sleep
(
10
)
count
=
[]
threads
=
[]
for
i
in
range
(
3
):
t1
=
threading
.
Thread
(
target
=
smoke
,
kwargs
=
{
'count'
:
count
})
t2
=
threading
.
Thread
(
target
=
drunk
,
kwargs
=
{
'count'
:
count
})
threads
.
append
(
t1
)
threads
.
append
(
t2
)
t1
.
start
()
t2
.
start
()
for
thread
in
threads
:
thread
.
join
()
print
(
str
(
count
))
# sleep(5) #
print
(
'---结束---:
%
s'
%
ctime
())
\ No newline at end of file
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