equal
deleted
inserted
replaced
124 scheduler = None |
124 scheduler = None |
125 |
125 |
126 if __name__ == '__main__': |
126 if __name__ == '__main__': |
127 from time import sleep |
127 from time import sleep |
128 logging.getLogger().setLevel(logging.INFO) |
128 logging.getLogger().setLevel(logging.INFO) |
|
129 if len(sys.argv) == 1: |
|
130 numberOfTasks = 100 |
|
131 else: |
|
132 numberOfTasks = int(sys.argv[1]) |
129 # This function is a sample and shouldn't know about the scheduler |
133 # This function is a sample and shouldn't know about the scheduler |
130 count = 0 |
134 count = 0 |
131 def AsyncCall(name, seconds): |
135 def AsyncCall(name, seconds): |
132 global count |
136 global count |
133 count += 1 |
137 count += 1 |
155 return task |
159 return task |
156 |
160 |
157 logging.info("Starting scheduler with 10 workers") |
161 logging.info("Starting scheduler with 10 workers") |
158 StartScheduler(10) |
162 StartScheduler(10) |
159 logging.info("Adding asynccall task") |
163 logging.info("Adding asynccall task") |
160 for x in xrange(int(sys.argv[1])): |
164 for x in xrange(numberOfTasks): |
161 task = AsyncCall("Toto%d" % (x+1), (x % 10)/10.0) |
165 task = AsyncCall("Toto%d" % (x+1), (x % 10)/10.0) |
162 scheduler.AddTask(task) |
166 scheduler.AddTask(task) |
163 while count > 0: |
167 while count > 0: |
164 logging.debug("Count = %d", count) |
168 logging.debug("Count = %d", count) |
165 sleep(1) |
169 sleep(1) |