triton icon indicating copy to clipboard operation
triton copied to clipboard

example_python使用多线程调用客户端,返回结果混乱

Open wanghaohw opened this issue 2 years ago • 1 comments

你好,我在example_python客户端里面加了多线程,每个线程去调用客户端,返回结果是混乱的,这应该怎么控制?

input0:[1,1,1,1]
input1:[2,2,2,2]

单线程:

--------------------------------------------
thread0
[3. 3. 3. 3.]
[-1. -1. -1. -1.]
--------------------------------------------

四个线程:

--------------------------------------------
thread0
[3. 3. 3. 3.]
[-1. -1. -1. -1.]
--------------------------------------------
--------------------------------------------
thread2
[3. 3. 3. 3.]
--------------------------------------------
[-1. -1. -1. -1.]
thread1
[3. 3. 3. 3.]
--------------------------------------------[-1. -1. -1. -1.]
--------------------------------------------
--------------------------------------------
thread3

[3. 3. 3. 3.]
[-1. -1. -1. -1.]
--------------------------------------------

Process finished with exit code 0

wanghaohw avatar Jun 09 '22 01:06 wanghaohw

@wanghaohw 可以分享一下您的代码吗?

打印结果混乱是不是因为没有加锁导致的呢?

zzk0 avatar Jun 23 '22 12:06 zzk0