Skip to content

Instantly share code, notes, and snippets.

@chantra
Created March 30, 2016 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chantra/36b73aabbe70b28a69a856f24d1274af to your computer and use it in GitHub Desktop.
Save chantra/36b73aabbe70b28a69a856f24d1274af to your computer and use it in GitHub Desktop.
diff --git a/demo/producer_consumer.py b/demo/producer_consumer.py
index 8d4a236..e80bf39 100644
--- a/demo/producer_consumer.py
+++ b/demo/producer_consumer.py
@@ -5,6 +5,7 @@
# of patent rights can be found in the PATENTS file in the same directory.
#
from six.moves import xrange
+from sparts.sparts import option
from sparts.tasks.periodic import PeriodicTask
from sparts.tasks.queue import QueueTask
from sparts.vservice import VService
@@ -23,6 +24,10 @@ class Producer(PeriodicTask):
INTERVAL = 1.0
DEPS = [Consumer]
+ foobar = option(
+ default=[],
+ nargs='*',
+ )
def initTask(self):
super(Producer, self).initTask()
self.consumer = self.service.tasks.Consumer
@@ -32,6 +37,7 @@ class Producer(PeriodicTask):
item = random.random()
self.consumer.queue.put(item)
self.logger.info("Producer put %s into queue", item)
+ self.logger.info("option foobar type: {} value: {}".format(type(self.foobar), self.foobar))
class ProducerConsumer(VService):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment