Пример #1
0
#!/usr/bin/python

from otpsetup.shortcuts import DjangoBrokerConnection
from otpsetup.shortcuts import stop_current_instance, build_multi_queue
from otpsetup import settings
from datetime import datetime
import traceback

import handlers

import process_gtfs, transformer

print "Starting Graph Builder Consumer"

queues = build_multi_queue(["create_instance", "rebuild_graph", "build_managed", "build_managed_osm", "process_gtfs"])

def handle(conn, body, message):
    
    key = message.delivery_info['routing_key']
    print "handling key "+key
    try: 
        getattr(handlers, key)(conn, body)
    except:
        print "gb handler error"
        now = datetime.now()
        errfile = "/var/otp/gb_err_%s_%s" % (key, now.strftime("%F-%T"))
        traceback.print_exc(file=open(errfile,"a"))
    message.ack()

with DjangoBrokerConnection() as conn:
Пример #2
0
#!/usr/bin/python

from otpsetup.shortcuts import DjangoBrokerConnection
from otpsetup.shortcuts import stop_current_instance, build_multi_queue
from otpsetup import settings
from datetime import datetime
import traceback

import handlers

import process_gtfs, transformer

print "Starting Graph Builder Consumer"

queues = build_multi_queue([
    "create_instance", "rebuild_graph", "build_managed", "build_managed_osm",
    "process_gtfs"
])


def handle(conn, body, message):

    key = message.delivery_info['routing_key']
    print "handling key " + key
    try:
        getattr(handlers, key)(conn, body)
    except:
        print "gb handler error"
        now = datetime.now()
        errfile = "/var/otp/gb_err_%s_%s" % (key, now.strftime("%F-%T"))
        traceback.print_exc(file=open(errfile, "a"))
    message.ack()
Пример #3
0
#!/usr/bin/python

from otpsetup.shortcuts import DjangoBrokerConnection
from otpsetup.shortcuts import stop_current_instance, build_multi_queue
from otpsetup import settings
from datetime import datetime
import traceback

import handlers

print "Starting Graph Builder Consumer"

queues = build_multi_queue(["create_instance", "rebuild_graph"])

def handle(conn, body, message):
    
    key = message.delivery_info['routing_key']
    print "handling key "+key
    try: 
        getattr(handlers, key)(conn, body)
    except:
        print "gb handler error"
        now = datetime.now()
        errfile = "/var/otp/gb_err_%s_%s" % (key, now.strftime("%F-%T"))
        traceback.print_exc(file=open(errfile,"a"))
    message.ack()

with DjangoBrokerConnection() as conn:

    with conn.Consumer(queues, callbacks=[lambda body, message: handle(conn, body, message)]) as consumer:
        # Process messages and handle events on all channels
Пример #4
0
#!/usr/bin/python

from kombu import Exchange, Queue
from otpsetup.shortcuts import DjangoBrokerConnection, build_multi_queue
from otpsetup import settings
from datetime import datetime
import traceback

import handlers

print "Starting Controller Consumer"

queues = build_multi_queue(["validation_done", "graph_done", "rebuild_graph_done", "managed_graph_done", "process_gtfs_done", "osm_extract_done", "deployment_ready", "proxy_done", "multideployer_ready", "multideployment_done"])

def handle(conn, body, message):
    
    key = message.delivery_info['routing_key']
    print "handling key "+key
    try: 
        getattr(handlers, key)(conn, body)
    except:
        print "handler error"
        now = datetime.now()
        errfile = "/var/otp/cc_err_%s_%s" % (key, now.strftime("%F-%T"))
        traceback.print_exc(file=open(errfile,"a"))
    message.ack()

with DjangoBrokerConnection() as conn:

    with conn.Consumer(queues, callbacks=[lambda body, message: handle(conn, body, message)]) as consumer:
        # Process messages and handle events on all channels