removed debug stuff from threaded.py

This commit is contained in:
Nikolay Markov 2012-09-11 17:19:57 +04:00 committed by default
parent df2ffdacc9
commit cb02adcbdd
2 changed files with 3 additions and 44 deletions

View File

@ -77,6 +77,8 @@ if __name__ == "__main__":
parser.print_help()
elif params.action in ("run", "runwsgi"):
from rpc import threaded
import eventlet
eventlet.monkey_patch()
q = threaded.rpc_queue
rpc_thread = threaded.RPCThread()

View File

@ -14,57 +14,14 @@ from api.models import engine
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):
def __init__(self, testmode=False):
def __init__(self):
super(RPCThread, self).__init__()
self.queue = rpc_queue
self.db = scoped_session(
sessionmaker(bind=engine, query_cls=Query)
)
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):
logging.info("Starting RPC thread...")