forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cms-sw#29 from amarini/topic_optimization
Topic optimization
- Loading branch information
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!env python | ||
|
||
#import os,sys | ||
from subprocess import call, check_output | ||
#import re | ||
import threading | ||
import time | ||
|
||
from optparse import OptionParser, OptionGroup | ||
|
||
usage = "usage: %prog [options] exe1 exe2 ..." | ||
parser=OptionParser(usage=usage) | ||
parser.add_option("-n","--ncore" ,dest='ncore',type='int',help="Input Datacard [Default=%default]",default=10) | ||
|
||
def call_exe(exe): | ||
print " -> Calling "+ exe | ||
call(exe,shell=True) | ||
print " -> Done "+exe | ||
|
||
(opts,args)=parser.parse_args() | ||
|
||
threads=[] | ||
|
||
for exe in args: | ||
while threading.activeCount() >= opts.ncore: | ||
print "sleep ...", | ||
time.sleep(3) | ||
print "wake up" | ||
t = threading.Thread(target=call_exe, args= (exe,) ) | ||
t.start() | ||
threads.append( t ) | ||
|
||
for t in threads: | ||
t.join() | ||
|
||
print "Done" | ||
|