On Thu, Feb 19, 2009 at 10:06 PM, David Cournapeau <courn...@gmail.com> wrote: > On Fri, Feb 20, 2009 at 11:43 AM, Maxim Khitrov <mkhit...@gmail.com> wrote: >> >> Yes, I may have a case where one thread is still sending data, while >> another tries to close the connection, or two threads trying to close >> the connection at the same time. In both cases, I need some parts of >> the code to be atomic to prevent errors. > > That does not sound like the right approach, then. Matlab engine is > not thread safe in that sense: > > http://www.mathworks.fr/support/solutions/data/1-YR98I.html?product=ML&solution=1-YR98I > > cheers, > > David >
"One option is to use MUTEXes around every call into the MATLAB Engine" - that's exactly what I'm doing. Some setup work, like creating mxArrays is done without a lock, but all eng* calls are mutually exclusive. I've been doing a lot of my own testing, and so far have seen no problems with this approach. - Max -- http://mail.python.org/mailman/listinfo/python-list