Add slightly better command line handling. default tip
authorFabien Ninoles <fabien@tzone.org>
Mon, 07 Jun 2010 23:56:53 -0400
changeset 6 6657247ddbbf
parent 5 eb1133af54ed
Add slightly better command line handling.
scheduler.py
--- a/scheduler.py	Sun Mar 21 21:47:48 2010 -0400
+++ b/scheduler.py	Mon Jun 07 23:56:53 2010 -0400
@@ -126,6 +126,10 @@
 if __name__ == '__main__':
     from time import sleep
     logging.getLogger().setLevel(logging.INFO)
+    if len(sys.argv) == 1:
+    	numberOfTasks = 100
+    else:
+        numberOfTasks = int(sys.argv[1])
     # This function is a sample and shouldn't know about the scheduler
     count = 0
     def AsyncCall(name, seconds):
@@ -157,7 +161,7 @@
     logging.info("Starting scheduler with 10 workers")
     StartScheduler(10)
     logging.info("Adding asynccall task")
-    for x in xrange(int(sys.argv[1])):
+    for x in xrange(numberOfTasks):
         task = AsyncCall("Toto%d" % (x+1), (x % 10)/10.0)
         scheduler.AddTask(task)
     while count > 0: