def initialize(self): _path = msg.join_path(self._path, 'initialize') msg.code_debug( _path, 'New connection established! {0} ' '({0.request.remote_ip})'.format(self)) self.local_pub_sub = OwnerPubSub(name='local_pub_sub') self.ws_pub_sub = OwnerPubSub(name='ws_pub_sub', send_function=self.write_message) self.ws_objects = { ws_class: ws_class(self) for ws_class in self.ws_classes } self.__class__.clients.add(self) self.__class__.client_count += 1 self.clean_closed = False self.ping_timeout_handle = None
from .common import db _path = 'src.db.message_broker' _coll_name = 'messages' _coll = db[_coll_name] cursor = None @coroutine def _send_message(message): yield _coll.insert(message) _ps = OwnerPubSub( name='db_pub_sub', send_function=_send_message ) # METHOD ALIASES: register = _ps.register send_message = _ps.send_message remove_owner = _ps.remove_owner @coroutine def _tailable_iteration(function: 'callable'=None, stop: bool=True, sleep: int=0): """Iterates through a tailable cursor. .. todo::