Example #1
0
def webhook(request):
    """ Handle github webhook. """

    # TODO -- check X-Hub-Signature

    salt = "TODO MAKE THIS SECRET"

    if 'payload' in request.params:
        payload = request.params['payload']
        if isinstance(payload, basestring):
            payload = json.loads(payload)

        queue = retask.queue.Queue('commits')
        task = retask.task.Task(payload)
        queue.connect()

        # Fire and forget
        job = queue.enqueue(task)
    else:
        raise NotImplementedError()

    return "OK"
Example #2
0
from utils import QueryPath, QueryCol, ParamFilter, WeightedSearch
from tg import config
from dogpile.cache import make_region
# TODO -- phase out beaker cache in favor of dogpile.
from beaker.cache import Cache
from kitchen.text.converters import to_bytes

import hashlib
import inspect
import retask.task
import retask.queue
import json

# Initialize an outgoing redis queue right off the bat.
queue = retask.queue.Queue('fedora-packages')
queue.connect()


def async_creation_runner(cache, somekey, creator, mutex):
    """ Used by dogpile.core:Lock when appropriate.

    Instead of directly computing the value, this instead adds a task to
    a redis queue with instructions for a worker on how to import and
    invoke function that we want.

    It also assumes the cache is backed by memcached and so provides the
    worker both with the cache key for the new value as well as the
    memcached key for the distributed mutex (so it can be released later).
    """

    # Re-use those artificial attributes that we stuck on the cached fns
#!/usr/bin/env python
import retask.queue
import socket
import time

interval = 2

hostname = socket.gethostname().split('.')[0]

queue = retask.queue.Queue('fedora-packages')
queue.connect()

while True:
    print "PUTVAL %s/redis/queue_length interval=%i %i:%i" % (
        hostname,
        interval,
        int(time.time()),
        queue.length,
    )
    time.sleep(interval)