more stuff

This commit is contained in:
j 2009-12-31 16:06:26 +01:00
parent f24b268352
commit 207e438e69
4 changed files with 42 additions and 0 deletions

20
oxdb/backend/daemon.py Normal file
View file

@ -0,0 +1,20 @@
from carrot.connection import DjangoBrokerConnection
from carrot.messaging import Consumer
def run():
conn = DjangoBrokerConnection()
consumer = Consumer(connection=conn, queue="oxdb-bg",
exchange="oxdb-bg",
routing_key="oxdb-bg")
def handle_background_tasks_callback(message_data, message):
print("Got feed import message")
print message_data
if 'loadIMDb' in message_data:
imdbId = message_data['loadIMDb']
load.loadIMDb(imdbId)
message.ack()
consumer.register_callback(handle_background_tasks_callback)
consumer.wait() # Go into the consumer loop.

View file

View file

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
# j@v2v.cc
import os
from os.path import join, dirname, basename, splitext, exists
from glob import glob
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from ... import daemon
class Command(BaseCommand):
"""
listen to rabbitmq and execute background dasks.
"""
help = 'listen to rabbitmq and execute background dasks.'
args = ''
def handle(self, **options):
daemon.run()