ShannonAI / service-streamer

Boosting your Web Services of Deep Learning Applications.
Apache License 2.0
1.23k stars 187 forks source link

python多线程问题 #51

Closed hxyshare closed 4 years ago

hxyshare commented 4 years ago

Thanks for your work. 因为python是伪多线程,在_loop_collect_result(self)函数和finished = self._finish_event.wait(timeout)会因为线程切换而导致40ms的多余开销,请问有什么的好的方法可以解决这个问题吗?

Meteorix commented 4 years ago

你可以试试用gevent,参考这里:https://github.com/ShannonAI/service-streamer/blob/ebcc3724efc9789feb8980641533909798d4d6dc/example/flask_multigpu_example.py#L4

另外:40ms是不太make sense的开销(即使对python来说),建议可以重新测一下

hxyshare commented 4 years ago

谢谢回答