Wednesday, 15 May 2013

windows - Shared file access between Python and Matlab -


I have a Matlab application which is one. Writes in the csv file and a Python script that reads from it. These operations happen together and at their respective time (not necessarily the same). It all runs on Windows 7

I want to know:

  1. Has the OS naturally provided some type of locking mechanism so that only one of the two applications - Matlab or Python - shared file You can use?
  2. In the Python application, how can I check that the file is already "open" by the Ed Matlab app? What is the loop structure for it, so that until the file is accessed for reading, the Python app is blocked?

  1. While the file is open to matlab , Then you can create an empty file "data.lock" or something in that effect.

  2. When Python tries to read the file, it will check the lock file, and if it is there, then it will sleep for a given interval.

  3. When matlab is done with the file, it may delete the "data.lock" file.

It is a programmatic solution, but it is easier to dig through windows API and find the right calls in matlab and python.


No comments:

Post a Comment