Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LockError on Windows #558

Open
maximegodin opened this issue Oct 10, 2019 · 1 comment
Open

LockError on Windows #558

maximegodin opened this issue Oct 10, 2019 · 1 comment

Comments

@maximegodin
Copy link

maximegodin commented Oct 10, 2019

Hello everyone!

I'm trying to use Whoosh on my Windows computer. The installation process works fine but I can't figure an error I'm getting.

I'm using the code snippet from the Quick start guide of the Whoosh documentation :

import whoosh.fields
import whoosh.index
import os

if __name__ == '__main__':

    schema = whoosh.fields.Schema(
        title=whoosh.fields.TEXT(stored=True), 
        content=whoosh.fields.TEXT,
        path=whoosh.fields.ID(stored=True), 
        tags=whoosh.fields.KEYWORD, 
        icon=whoosh.fields.STORED
    )
    
    
    if not os.path.exists("index"):
        os.mkdir("index")
    ix = whoosh.index.create_in("index", schema)
    
    writer = ix.writer()
    writer.add_document(title=u"My document", content=u"This is my document!",
                        path=u"/a", tags=u"first short", icon=u"/icons/star.png")
    writer.add_document(title=u"Second try", content=u"This is the second example.",
                        path=u"/b", tags=u"second short", icon=u"/icons/sheep.png")
    writer.add_document(title=u"Third time's the charm", content=u"Examples are many.",
                        path=u"/c", tags=u"short", icon=u"/icons/book.png")
    writer.commit()

I get the following error:

Traceback (most recent call last):
  File "whoosh_test.py", line 22, in <module>
    writer = ix.writer()
  File "C:\Users\***\AppData\Roaming\Python\Python36\site-packages\whoosh\index.py", line 464, in writer
    return SegmentWriter(self, **kwargs)
  File "C:\Users\***\AppData\Roaming\Python\Python36\site-packages\whoosh\writing.py", line 515, in __init__
    raise LockError
whoosh.index.LockError

I'm using the latest version of Whoosh (2.7.4) on Windows 10 with Python 3.6.

Does someone have any insight on this issue ?

Thanks you !

@stevennic
Copy link
Contributor

Are you by any chance trying to write from two places simultaneously? For example, do you have two active debug sessions on this code? When your code isn't running, use Process Explorer to see if if any process has a handle on the lock file: MAIN_WRITELOCK. If so, that is the process that's holding a lock on your index. Kill the process or close the handle to release it.

If that's not it I wonder if it's some kind of permission issue on the lock file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants