繁体   English   中英

python whoosh IndexingError 中断时

[英]python whoosh IndexingError when interrupted

在我中断 whoosh 提交过程后出现这个奇怪的错误。 当我现在尝试提交时,我得到了

  File "/usr/local/lib/python2.7/dist-packages/whoosh/filedb/filewriting.py", line 179, in     _check_state
    raise IndexingError("This writer is closed")
whoosh.writing.IndexingError: This writer is closed

我尝试重新安装 lib,更改索引目录但它不起作用。 那么我该如何修复嗖嗖声呢?

我认为没有必要“修复 whoosh”(或索引)。

可能只是您的代码打开了一个编写器,可能使用它,关闭它,然后再次尝试使用关闭的编写器。

总是这样做:

with myindex.writer() as w:
    w.add_document(title=u"First document", content=u"Hello there.")
    w.add_document(title=u"Second document", content=u"This is easy!")

如果您稍后需要添加更多文档(在此“with”-块之外),请以相同的方式打开一个新的编写器...

注意:writer w 在离开 with-block 时会自动关闭,这就是所谓的上下文管理器的工作原理。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM