removed debug stuff from threaded.py
This commit is contained in:
parent
df2ffdacc9
commit
cb02adcbdd
@ -77,6 +77,8 @@ if __name__ == "__main__":
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
elif params.action in ("run", "runwsgi"):
|
elif params.action in ("run", "runwsgi"):
|
||||||
from rpc import threaded
|
from rpc import threaded
|
||||||
|
import eventlet
|
||||||
|
eventlet.monkey_patch()
|
||||||
q = threaded.rpc_queue
|
q = threaded.rpc_queue
|
||||||
rpc_thread = threaded.RPCThread()
|
rpc_thread = threaded.RPCThread()
|
||||||
|
|
||||||
|
@ -14,57 +14,14 @@ from api.models import engine
|
|||||||
rpc_queue = Queue.Queue()
|
rpc_queue = Queue.Queue()
|
||||||
|
|
||||||
|
|
||||||
class TestReceiver(object):
|
|
||||||
"""Simple Proxy class so the consumer has methods to call.
|
|
||||||
|
|
||||||
Uses static methods because we aren't actually storing any state.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def echo(value):
|
|
||||||
"""Simply returns whatever value is sent in."""
|
|
||||||
return value
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def multicall_three_nones(value):
|
|
||||||
yield None
|
|
||||||
yield None
|
|
||||||
yield None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def echo_three_times_yield(value):
|
|
||||||
yield value
|
|
||||||
yield value + 1
|
|
||||||
yield value + 2
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def fail(value):
|
|
||||||
"""Raises an exception with the value sent in."""
|
|
||||||
raise Exception(value)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def block(value):
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
|
|
||||||
import eventlet
|
|
||||||
eventlet.monkey_patch()
|
|
||||||
|
|
||||||
|
|
||||||
class RPCThread(threading.Thread):
|
class RPCThread(threading.Thread):
|
||||||
def __init__(self, testmode=False):
|
def __init__(self):
|
||||||
super(RPCThread, self).__init__()
|
super(RPCThread, self).__init__()
|
||||||
self.queue = rpc_queue
|
self.queue = rpc_queue
|
||||||
self.db = scoped_session(
|
self.db = scoped_session(
|
||||||
sessionmaker(bind=engine, query_cls=Query)
|
sessionmaker(bind=engine, query_cls=Query)
|
||||||
)
|
)
|
||||||
self.conn = rpc.create_connection(True)
|
self.conn = rpc.create_connection(True)
|
||||||
self.testmode = testmode
|
|
||||||
if not self.testmode:
|
|
||||||
self.receiver = TestReceiver()
|
|
||||||
self.conn.create_consumer('test', self.receiver, False)
|
|
||||||
self.conn.consume_in_thread()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
logging.info("Starting RPC thread...")
|
logging.info("Starting RPC thread...")
|
||||||
|
Loading…
Reference in New Issue
Block a user