Python embedding with threads — avoiding deadlocks?

人走茶凉 提交于 2019-12-05 04:54:15

"When calling into Python, I may need to hold the same locks, because I may be iterating over some collection of objects, for example."

This often indicates that a single process with multiple threads isn't appropriate. Perhaps this is a situation where multiple processes -- each with a specific object from the collection -- makes more sense.

Independent process -- each with their own pool of threads -- may be easier to manage.

The code that is called by python should release the GIL before taking any of your locks. That way I believe it can't get into the dead-lock.

There was recently some discussion of a similar issue on the pyopenssl list. I'm afraid if I try to explain this I'm going to get it wrong, so instead I'll refer you to the problem in question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!