removed global cursor (unnecessary)

This commit is contained in:
Albert S. 2018-08-09 22:51:21 +02:00
parent d1d317d5af
commit 4de5aa6d74

View File

@ -114,7 +114,7 @@ def exists(abspath, mtime):
return True return True
return False return False
def insert(path, cursor): def insert(path):
print("processing", path) print("processing", path)
abspath=os.path.abspath(path) abspath=os.path.abspath(path)
mtime = int(os.stat(abspath).st_mtime) mtime = int(os.stat(abspath).st_mtime)
@ -151,24 +151,21 @@ preprocess={".pdf":process_pdf, ".odt":process_odt, ".html":process_striptags, "
def yieldstdinfiles(): def yieldstdinfiles():
for line in sys.stdin: for line in sys.stdin:
yield line.replace("\n", "") yield line.replace("\n", "")
def poolinserter(path):
insert(path, cursor)
def init(): def init():
global cursor
global dbcon global dbcon
dbcon = sqlite3.connect(config.DBPATH, isolation_level=None) dbcon = sqlite3.connect(config.DBPATH, isolation_level=None)
cursor = None
dbcon = None dbcon = None
if __name__ == '__main__': if __name__ == '__main__':
with Pool(processes=4,initializer=init) as pool: with Pool(processes=4,initializer=init) as pool:
if len(sys.argv) < 2: if len(sys.argv) < 2:
pool.map(poolinserter, yieldstdinfiles) pool.map(insert, yieldstdinfiles)
else: else:
pool.map(poolinserter, sys.argv[1:]) pool.map(insert, sys.argv[1:])