# Bunch from bunch import Bunch # Redis import redis # Zato from zato.common import BROKER, TRACE1, ZATO_NONE from zato.common.broker_message import KEYS, MESSAGE_TYPE, TOPICS from zato.common.kvdb import LuaContainer from zato.common.util import new_cid logger = logging.getLogger(__name__) REMOTE_END_CLOSED_SOCKET = 'Socket closed on remote end' NEEDS_TMP_KEY = [v for k,v in TOPICS.items() if k in( MESSAGE_TYPE.TO_PARALLEL_ANY, )] CODE_RENAMED = 10 CODE_NO_SUCH_FROM_KEY = 11 def BrokerClient(kvdb, client_type, topic_callbacks, _initial_lua_programs): # Imported here so it's guaranteed to be monkey-patched using gevent.monkey.patch_all by whoever called us from thread import start_new_thread class _ClientThread(object): def __init__(self, kvdb, pubsub, name, topic_callbacks=None, on_message=None): self.kvdb = kvdb self.pubsub = pubsub
from zato.common.broker_message import KEYS, MESSAGE_TYPE, TOPICS from zato.common.kvdb import LuaContainer from zato.common.util import new_cid logger = logging.getLogger(__name__) REMOTE_END_CLOSED_SOCKET = 'Socket closed on remote end' FILE_DESCR_CLOSED_IN_ANOTHER_GREENLET = "Error while reading from socket: (9, 'File descriptor was closed in another greenlet')" # We use textual messages because some error may have codes whereas different won't. EXPECTED_CONNECTION_ERRORS = [ REMOTE_END_CLOSED_SOCKET, FILE_DESCR_CLOSED_IN_ANOTHER_GREENLET ] NEEDS_TMP_KEY = [ v for k, v in TOPICS.items() if k in (MESSAGE_TYPE.TO_PARALLEL_ANY, ) ] CODE_RENAMED = 10 CODE_NO_SUCH_FROM_KEY = 11 def BrokerClient(kvdb, client_type, topic_callbacks, _initial_lua_programs): # Imported here so it's guaranteed to be monkey-patched using gevent.monkey.patch_all by whoever called us from thread import start_new_thread class _ClientThread(object): def __init__(self, kvdb, pubsub,
# Zato from zato.common import BROKER, ZATO_NONE from zato.common.broker_message import KEYS, MESSAGE_TYPE, TOPICS from zato.common.kvdb import LuaContainer from zato.common.util import new_cid, spawn_greenlet logger = logging.getLogger(__name__) has_debug = logger.isEnabledFor(logging.DEBUG) REMOTE_END_CLOSED_SOCKET = 'Socket closed on remote end' FILE_DESCR_CLOSED_IN_ANOTHER_GREENLET = "Error while reading from socket: (9, 'File descriptor was closed in another greenlet')" # We use textual messages because some error may have codes whereas different won't. EXPECTED_CONNECTION_ERRORS = [REMOTE_END_CLOSED_SOCKET, FILE_DESCR_CLOSED_IN_ANOTHER_GREENLET] NEEDS_TMP_KEY = [v for k,v in TOPICS.items() if k in( MESSAGE_TYPE.TO_PARALLEL_ANY, )] CODE_RENAMED = 10 CODE_NO_SUCH_FROM_KEY = 11 def BrokerClient(kvdb, client_type, topic_callbacks, _initial_lua_programs): # Imported here so it's guaranteed to be monkey-patched using gevent.monkey.patch_all by whoever called us from zato.common.py23_ import start_new_thread class _ClientThread(object): def __init__(self, kvdb, pubsub, name, topic_callbacks=None, on_message=None): self.kvdb = kvdb.copy() self.kvdb.init()
from zato.common import BROKER, TRACE1, ZATO_NONE from zato.common.broker_message import KEYS, MESSAGE_TYPE, TOPICS from zato.common.kvdb import LuaContainer from zato.common.util import new_cid logger = logging.getLogger(__name__) REMOTE_END_CLOSED_SOCKET = "Socket closed on remote end" FILE_DESCR_CLOSED_IN_ANOTHER_GREENLET = ( "Error while reading from socket: (9, 'File descriptor was closed in another greenlet')" ) # We use textual messages because some error may have codes whereas different won't. EXPECTED_CONNECTION_ERRORS = [REMOTE_END_CLOSED_SOCKET, FILE_DESCR_CLOSED_IN_ANOTHER_GREENLET] NEEDS_TMP_KEY = [v for k, v in TOPICS.items() if k in (MESSAGE_TYPE.TO_PARALLEL_ANY,)] CODE_RENAMED = 10 CODE_NO_SUCH_FROM_KEY = 11 def BrokerClient(kvdb, client_type, topic_callbacks, _initial_lua_programs): # Imported here so it's guaranteed to be monkey-patched using gevent.monkey.patch_all by whoever called us from thread import start_new_thread class _ClientThread(object): def __init__(self, kvdb, pubsub, name, topic_callbacks=None, on_message=None): self.kvdb = kvdb self.pubsub = pubsub self.topic_callbacks = topic_callbacks