[英]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.