Skip to content

Commit

Permalink
first commit for django-pyres
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt George committed Jun 4, 2012
0 parents commit 470fc80
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.pyc
build/
.coverage
*.egg-info
dist/
3 changes: 3 additions & 0 deletions django_pyres/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
VERSION = (0, 1, 0)
__version__ = '.'.join(map(str, VERSION))

14 changes: 14 additions & 0 deletions django_pyres/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.conf import settings #noqa
from appconf import AppConf

class PyresConf(AppConf):
HOST = "localhost:6379"
PASSWORD = None
WORKER_PIDFILE = None
WORKER_INTERVAL = None
WORKER_LOGFILE = None
WORKER_TIMEOUT= None
MANAGER_POOL_SIZE=2

class Meta:
prefix = 'pyres'
4 changes: 4 additions & 0 deletions django_pyres/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pyres import ResQ
from django.conf import settings
pyres = ResQ(getattr(settings,'PYRES_HOST','localhost:6379'),getattr(settings,'PYRES_PASSWORD',None))

Empty file.
Empty file.
29 changes: 29 additions & 0 deletions django_pyres/management/commands/pyres_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging
from django.core.management.base import BaseCommand, CommandError
from django_pyres.conf import settings

from optparse import make_option
from pyres.horde import Khan
from pyres import setup_pidfile

class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option("--pool", type="int", dest="pool_size", default=0, help="Number of minions to spawn under the manager."),
make_option('-l', '--log-level', dest='log_level', default='info', help='log level. Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.'),
make_option('-f', dest='logfile', help='If present, a logfile will be used. "stderr", "stdout", and "syslog" are all special values.'),
)
help = 'Closes the specified poll for voting'

def handle(self, queue_list, **options):
queues = queue_list.split(',')
log_level = getattr(logging, options['log_level'].upper(), 'INFO')
pool_size = options.get('pool_size')
if pool_size == 0:
pool_size = settings.PYRES_MANAGER_POOL_SIZE
setup_pidfile(settings.PYRES_WORKER_PIDFILE)
Khan.run(
pool_size=pool_size,
queues=queues,
server=settings.PYRES_HOST,
logging_level=log_level,
log_file=None)
27 changes: 27 additions & 0 deletions django_pyres/management/commands/pyres_worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import logging
from django.core.management.base import BaseCommand, CommandError
from django_pyres.conf import settings

from optparse import make_option
from pyres.worker import Worker
from pyres import setup_logging, setup_pidfile

class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('-l', '--log-level', dest='log_level', default='info', help='log level. Valid values are "debug", "info", "warning", "error", "critical", in decreasing order of verbosity. Defaults to "info" if parameter not specified.'),
)
help = 'Closes the specified poll for voting'

def handle(self, queue_list, **options):
queues = queue_list.split(',')
log_level = getattr(logging, options['log_level'].upper(), 'INFO')
setup_logging(procname="pyres_worker", log_level=log_level, filename=None)
setup_pidfile(settings.PYRES_WORKER_PIDFILE)
Worker.run(
queues,
settings.PYRES_HOST,
settings.PYRES_WORKER_INTERVAL,
timeout=settings.PYRES_WORKER_TIMEOUT
)


2 changes: 2 additions & 0 deletions django_pyres/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from django.db import models
# Create your models here.
1 change: 1 addition & 0 deletions django_pyres/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your views here.
25 changes: 25 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from setuptools import setup, find_packages
version=__import__('django_pyres').__version__
setup(
name='django_pyres',
version=version,
description='django pyres ',
author='Matt George',
author_email='[email protected]',
maintainer='Matt George',
license='MIT',
url='http://github.com/Pyres/django_pyres',
packages=find_packages(exclude=['ez_setup', 'example','testapp','tests']),
include_package_data=True,
install_requires=[
'pyres>=1.3',
],
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python'],
)

0 comments on commit 470fc80

Please sign in to comment.