示例#1
0
文件: event.py 项目: sankopay/IBSng
    def doEvent(self):
        self.tlock.acquire()
        try:
            job = self.__events.pop(0)
        finally:
            self.tlock.release()

        if defs.LOG_EVENTS:
            toLog(
                "Event Scheduler: Running Method:%s Arguments: %s" %
                (job["method"], job["args"]), LOG_DEBUG)

        if job["priority"] == 100:  #run shutdown method in main thread, not a new thread
            apply(job["method"], job["args"])
        else:

            if job["priority"] < 10:
                twrapper = "event"
            else:
                twrapper = "main"

            try:
                thread_main.runThread(job["method"], job["args"], twrapper)
            except:
                logException(LOG_ERROR, "Unhandled exception on event loop")
示例#2
0
 def killInstance(self, instance):
     """
         should be called while online lock has been held
     """
     self.user_obj.getInstanceInfo(instance)["killed"] = True
     user_msg = self.user_obj.createUserMsg(instance, "KILL_USER")
     thread_main.runThread(user_msg.send, [])
示例#3
0
文件: server.py 项目: sankopay/IBSng
def startServer():

    stat_main.getStatKeeper().registerStat("server_avg_response_time",
                                           "seconds")
    stat_main.getStatKeeper().registerStat("server_max_response_time",
                                           "seconds")
    stat_main.getStatKeeper().registerStat("server_total_requests", "int")

    global server_started
    server_started = True
    thread_main.runThread(server.serve_forever, [], "server")
示例#4
0
def init():
    global radius_server_started
    if defs.RADIUS_SERVER_ENABLED==0:
	return

    toLog("Initializing IBS Radius Server",LOG_DEBUG)
    global ibs_dic
    ibs_dic=dictionary.Dictionary("%s/radius_server/dictionary"%defs.IBS_ROOT)
    srv=IBSRadiusServer(dict=ibs_dic,addresses=defs.RADIUS_SERVER_BIND_IP,authport=defs.RADIUS_SERVER_AUTH_PORT,acctport=defs.RADIUS_SERVER_ACCT_PORT)
    srv.hosts=ras_main.getLoader().getRadiusRemoteHosts()
    thread_main.runThread(srv.Run,[],"radius")
    radius_server_started=True
示例#5
0
    def __setStartupEvents(self):
	for _index in range(len(self.events)):
	    ev=self.events[_index]

	    if self.debug:
		toLog("Startup PeriodicEvent: Running %s run_at_start_up %s args %s"%(ev.name,ev.run_at_startup,ev.args),LOG_DEBUG)

	    if ev.run_at_startup==1:
	        thread_main.runThread(ev.run,ev.args,"event")
	    elif ev.run_at_startup==2:
		apply(ev.run,ev.args)
	    
	    self.__setNextEvent(_index)
示例#6
0
    def __setStartupEvents(self):
        for _index in range(len(self.events)):
            ev=self.events[_index]

            if self.debug:
                toLog("Startup PeriodicEvent: Running %s run_at_start_up %s args %s"%(ev.name,ev.run_at_startup,ev.args),LOG_DEBUG)

            if ev.run_at_startup==1:
                thread_main.runThread(ev.run,ev.args,"event")
            elif ev.run_at_startup==2:
                apply(ev.run,ev.args)
            
            self.__setNextEvent(_index)
示例#7
0
文件: event.py 项目: moxwose/freeIBS
    def doEvent(self):
	self.tlock.acquire()
	try:
		job=self.__events.pop(0)
	finally:
	    self.tlock.release()
	
	if defs.LOG_EVENTS:
	    toLog("Event Scheduler: Running Method:%s Arguments: %s"%(job["method"],job["args"]),LOG_DEBUG)
	
	if job["priority"]==100: #run shutdown method in main thread, not a new thread
            apply(job["method"],job["args"])
	else:
    	    try:
            	thread_main.runThread(job["method"],job["args"],"event")
    	    except:
        	logException(LOG_ERROR,"Unhandled exception on event loop")
示例#8
0
文件: server.py 项目: moxwose/freeIBS
	def _ProcessInput(self, fd):
		"""Process available data.

		If this packet should be dropped instead of processed a
		PacketError exception should be raised. The main loop will
		drop the packet and log the reason.

		This function calls either HandleAuthPacket() or
		HandleAcctPacket() depending on which socket is being
		processed.

		@param  fd: socket to read packet from
		@type   fd: socket class instance
		"""
		if fd.fileno() in self._realauthfds:
			pkt=self._GrabPacket(lambda data, s=self: s.CreateAuthPacket(packet=data), fd)
			thread_main.runThread(self._HandleAuthPacket,(fd, pkt),"radius")
		else:
			pkt=self._GrabPacket(lambda data, s=self: s.CreateAcctPacket(packet=data), fd)
			thread_main.runThread(self._HandleAcctPacket,(fd, pkt),"radius")
示例#9
0
    def killInstance(self,instance):
	user_msg=self.user_obj.createUserMsg(instance,"KILL_USER")
	thread_main.runThread(user_msg.send,[])
示例#10
0
def startServer():
    thread_main.runThread(server.serve_forever, [], "server")
示例#11
0
 def process_request(self, request, client_address):
     if not main.isShuttingDown() and not main.noLoginSet():
         thread_main.runThread(self.process_request_thread,
                               [request, client_address], "server")
示例#12
0
 def process_request(self, request, client_address):
     if not main.isShuttingDown() and not main.noLoginSet():
         thread_main.runThread(self.process_request_thread, [request, client_address], "server")
示例#13
0
def startRadiusServer():

    from radius_server.rad_server import IBSRadiusServer
    srv = IBSRadiusServer(dict=ibs_dic, addresses=defs.RADIUS_SERVER_BIND_IP, authport=defs.RADIUS_SERVER_AUTH_PORT, acctport=defs.RADIUS_SERVER_ACCT_PORT)
    srv.hosts = ras_main.getLoader().getRadiusRemoteHosts()
    thread_main.runThread(srv.Run,[],"radius")
示例#14
0
from core.threadpool import thread_main
import time


def sleep():
    time.sleep(60)


for i in range(10):
    thread_main.runThread(sleep, [], "event")