epigen-UCSD / snATAC_preprocess

0 stars 0 forks source link

multi-threading #2

Open biomystery opened 6 years ago

biomystery commented 6 years ago

https://stackoverflow.com/questions/22147166/parallel-excution-and-file-writing-on-python?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

!/usr/bin/env python

from multiprocessing import Pool

def compute_cluster(c): """each cluster can be computed independently""" ... # compute a cluster here

if name=="main": pool = Pool(10) # run 10 task at most in parallel pool.map(compute_cluster, range(10))