Moved jobs examples to docs repo

These are not considered "examples", per
https://github.com/kubernetes/kubernetes/pull/17345#issuecomment-197153744
This commit is contained in:
Eric Tune
2016-06-20 07:59:19 -07:00
parent 1cd9b83b54
commit 72a3fb3c37
15 changed files with 957 additions and 12 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env python
import time
import rediswq
host="redis"
# Uncomment next two lines if you do not have Kube-DNS working.
# import os
# host = os.getenv("REDIS_SERVICE_HOST")
q = rediswq.RedisWQ(name="job2", host="redis")
print("Worker with sessionID: " + q.sessionID())
print("Initial queue state: empty=" + str(q.empty()))
while not q.empty():
item = q.lease(lease_secs=10, block=True, timeout=2)
if item is not None:
itemstr = item.decode("utf=8")
print("Working on " + itemstr)
time.sleep(10) # Put your actual work here instead of sleep.
q.complete(item)
else:
print("Waiting for work")
print("Queue empty, exiting")