hayd / pep8radius

PEP8 clean only the parts of the files touched since the last commit, a previous commit or (the merge-base of) a branch.
MIT License
183 stars 9 forks source link

add a jobs argument #19

Open hayd opened 10 years ago

hayd commented 10 years ago

autopep8 has a jobs argument:

-j n, --jobs n        number of parallel jobs; match CPU count if value is less than 1

This would be great to have, if someone wanted to pick this up. Presumably you'd deal with each file separately (i.e. where it iterates over filenames_diff).

This is less useful than autopep8's as by definition (?) we ought to be acting on a smaller set of fixes (and it should usually take less time than a full autopep8 pass).

hayd commented 10 years ago

Note: Can use multiprocessing with a manager (cleverly does all the locking for the shared object, I think this lend well to that):

d = multiprocessing.Manager().dict()
# here f updates d with filename -> diff
procs = [multiprocessing.Process(target=f, args=(file_name, d,)) for filename in filenames)]  # or pass in d as default arg to f
for p in procs: p.start()
for p in procs: p.join()  # wait until they terminate
# Can iterate/print the result from d

Obviously should turn off verbosity printing while it's doing this (can reset it back after maybe)