Forum

Author Topic: Passing document object from function to function creates lock file  (Read 3459 times)

laxman

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hi Alexey,

I am using standalone python module for metashape version 1.8.5. I have a sample code snippet like below:

Code: [Select]
def return_doc_chunk():
    doc = Metashape.Document()
    doc.open("project.psx")
    chunk = doc.chunk
    return doc, chunk

def save_doc(doc, chunk):
    print(doc, doc.read_only, chunk)
    doc.save()

doc, chunk = return_doc_chunk()
# Now check in the project.files/ directory. There will be lock file

save_doc(doc, chunk) # lock file will still exist

If u move the doc.save() into return_doc_chunk then lock file will not be there.

So my question is why is the lock file in the project_files directory when I pass doc object from function to function meaning I create the doc object in one function and pass the doc object through successive functions and then do doc.save() in the final function? But the lock is removed if I create and save the doc object in the same function? I would like to know how to pass the doc object between functions and the lock file to be removed automatically when I do doc.save() in the different function.