def __init__(self, ccnet_dir, args, events_listener_enabled=True, background_tasks_enabled=True): self._ccnet_dir = ccnet_dir self._central_config_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR') self._args = args self._events_listener_enabled = events_listener_enabled self._bg_tasks_enabled = background_tasks_enabled try: load_config(args.config_file) except Exception as e: logging.error('Error loading seafevents config. Detial: %s' % e) raise RuntimeError("Error loading seafevents config. Detial: %s" % e) self._events_listener = None if self._events_listener_enabled: self._events_listener = EventsMQListener(self._args.config_file) if appconfig.publish_enabled: events_publisher.init() else: logging.info("Events publish to redis is disabled.") self._bg_tasks = None if self._bg_tasks_enabled: self._bg_tasks = BackgroundTasks(args.config_file) if appconfig.enable_statistics: self.update_login_record_task = CountUserActivity() self.count_traffic_task = CountTrafficInfo() self._ccnet_session = None self._sync_client = None self._evbase = libevent.Base() #pylint: disable=E1101 self._sighandler = SignalHandler(self._evbase)
def main(): init_logging() evbase = libevent.Base() session = AsyncClient(CCNET_CONF_DIR, evbase) session.connect_daemon() register_rpc_functions(session) session.main_loop()
def main(): # the classic hello world example... # we need an event base that will hold the events base = libevent.Base() print 'Initialized base with %r backend' % (base.method) # create listening socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 1234)) s.listen(1) print 'Running on %s:%d' % s.getsockname() # wait for client connection conn, addr = s.accept() conn.setblocking(False) print 'Connected from %s:%d' % addr bev = libevent.BufferEvent(base, conn.fileno()) bev.set_callbacks(readable, writable, event_received) bev.enable(libevent.EV_READ) bev.set_timeouts(5, 5) # run event loop until termination base.loop()
def main(): # the classic hello world example... # we need an event base that will hold the events base = libevent.Base() print 'Initialized base with %r backend' % (base.method) # create listening socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('localhost', 1234)) s.listen(1) print 'Running on %s:%d' % s.getsockname() # wait for client connection conn, addr = s.accept() conn.setblocking(False) print 'Connected from %s:%d' % addr # add event that waits for available data with a timeout of 5 seconds evt = libevent.Event(base, conn.fileno(), libevent.EV_READ | libevent.EV_PERSIST, event_ready, conn) evt.add(5) # run event loop until termination base.loop()
def create_process(self, device): logger.debug('*** Running _create_process ***') self.base = libevent.Base() self.client_id = str(uuid.uuid4()) self._init_mqclient() self._proc_init(device) self.base.dispatch() logging.info("Process Exit ...")
def __init__(self, client_id): self.base = libevent.Base() self.logger = Logger() self.mqclient = MQClient(client_id, max_queue_size=10, after_connect=self._after_connect, on_connected=self._on_connected, on_disconnected=self._on_disconnected, logger=self.logger) self.readEvt = None self.writeEvt = None self.timer = libevent.Timer(self.base, self._timerHandle, userdata=None) self.sig = libevent.Signal(self.base, signal.SIGINT, self._on_signal_handler) self.topic = 'local/py/test' self.msg_id = 0
def __init__(self, ccnet_dir, args, events_listener_enabled=True): self._ccnet_dir = ccnet_dir self._central_config_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR') self._args = args self._events_listener_enabled = events_listener_enabled try: load_config(args.config_file) except Exception as e: logging.error('Error loading seafevents config. Detial: %s' % e) raise RuntimeError("Error loading seafevents config. Detial: %s" % e) self._events_listener = None if self._events_listener_enabled: self._events_listener = EventsMQListener(self._args.config_file) self._ccnet_session = None self._sync_client = None self._evbase = libevent.Base() #pylint: disable=E1101 self._sighandler = SignalHandler(self._evbase)
def createBase(self): return libevent.Base()
def initLibEvent(self): return libevent.Base()
def createBase(self, *args): return libevent.Base(*args)
def __init__(self): self.base = libevent.Base() # Initialize libevent base instance self.pushinfo = MessagePush(self.base, INOS_PUSH_ADDR) # Register info channel self.mainLogger = Logger() TimerEvtHandle.__init__(self, self.base, 10) # Set the default timer, 10S.