0

Cleanup even more

This commit is contained in:
Patrick-Emmanuel Boulanger-Nadeau
2013-10-01 13:13:14 -04:00
parent f90b1ae6a4
commit 55f7183c4d

View File

@@ -60,7 +60,7 @@ def parseBucketChunks(bucket, rset):
return pois return pois
def handleEntities(rset, outputdir, render, rname): def handleEntities(rset, outputdir, render, rname, config):
# if we're already handled the POIs for this region regionset, do nothing # if we're already handled the POIs for this region regionset, do nothing
if hasattr(rset, "_pois"): if hasattr(rset, "_pois"):
@@ -71,30 +71,40 @@ def handleEntities(rset, outputdir, render, rname):
filters = render['markers'] filters = render['markers']
rset._pois = dict(TileEntities=[], Entities=[]) rset._pois = dict(TileEntities=[], Entities=[])
numbuckets = 8; numbuckets = config['processes'];
buckets = [[] for i in range(numbuckets)]; if numbuckets < 0:
numbuckets = multiprocessing.cpu_count()
for (x,z,mtime) in rset.iterate_chunks(): if numbuckets == 1:
i = x / 32 + z / 32 for (x,z,mtime) in rset.iterate_chunks():
i = i % numbuckets data = rset.get_chunk(x,z)
buckets[i].append([x,z]) rset._pois['TileEntities'] += data['TileEntities']
rset._pois['Entities'] += data['Entities']
for b in buckets: else:
logging.info("Buckets has %d entries", len(b)); buckets = [[] for i in range(numbuckets)];
# create the partial to lock the rset for (x,z,mtime) in rset.iterate_chunks():
dest = partial(parseBucketChunks, rset=rset) i = x / 32 + z / 32
i = i % numbuckets
buckets[i].append([x,z])
# Create a pool of processes and run all the functions for b in buckets:
pool = Pool(processes=numbuckets) logging.info("Buckets has %d entries", len(b));
results = pool.map(dest, buckets)
logging.info("All the threads completed") # create the partial to lock the rset
dest = partial(parseBucketChunks, rset=rset)
# Fix up all the quests in the reset # Create a pool of processes and run all the functions
for data in results: pool = Pool(processes=numbuckets)
rset._pois['TileEntities'] += data['TileEntities'] results = pool.map(dest, buckets)
rset._pois['Entities'] += data['Entities']
logging.info("All the threads completed")
# Fix up all the quests in the reset
for data in results:
rset._pois['TileEntities'] += data['TileEntities']
rset._pois['Entities'] += data['Entities']
logging.info("Done.") logging.info("Done.")
@@ -233,7 +243,7 @@ def main():
markers[rname] = [to_append] markers[rname] = [to_append]
if not options.skipscan: if not options.skipscan:
handleEntities(rset, os.path.join(destdir, rname), render, rname) handleEntities(rset, os.path.join(destdir, rname), render, rname, config)
handlePlayers(rset, render, worldpath) handlePlayers(rset, render, worldpath)
handleManual(rset, render['manualpois']) handleManual(rset, render['manualpois'])