Commits

Donald Stufft committed 17c0013

Add a script to enable configuring the worker

  • Participants
  • Parent commits c4aaab9

Comments (0)

Files changed (1)

File tools/worker.py

+#!/usr/bin/env python
+import os
+import os.path
+import sys
+
+import redis
+import rq
+
+# Workaround current bug in docutils:
+# http://permalink.gmane.org/gmane.text.docutils.devel/6324
+import docutils.utils
+
+# Make sure our PyPI directory is on the sys.path
+root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path = [root] + sys.path
+
+import config
+
+
+conf = config.Config(os.environ.get("PYPI_CONFIG", "/data/pypi/config.ini"))
+redis_conn = redis.Redis.from_url(conf.redis_url)
+
+if sys.argv[1:]:
+    queues = [rq.Queue(name, connection=redis_conn) for name in sys.argv[1:]]
+else:
+    queues = [rq.Queue(connection=redis_conn)]
+
+worker = rq.Worker(queues, connection=redis_conn)
+worker.work()