示例#1
0
class SessionManagement(Process):
    def __init__(self, aps_instance, queue, queue2, queue_sync, logging_queue):
        Process.__init__(self)

        self.aps_instance = aps_instance
        self.queue = queue
        self.queue2 = queue2
        self.queue_sync = queue_sync
        self.logging_queue = logging_queue

        self.synchronizer = SingletonSynchronizer()
        self.synchronizer.backup()
        self.looping = True

        self.current_session_id = multiprocessing.Array("c", 30)

    def run(self):
        try:
            self.main()
        except Exception, err:
            from ovd.Config import Config
            import os
            import time
            import traceback
            try:
                f = open("%s-crash-%d.txt" % (Config.log_file, os.getpid()),
                         "a")
                f.write("%s - Unhandled exception: \n" % (time.asctime()))
                f.write(traceback.format_exc())
                f.close()
            except IOError, err:
                pass

            raise err  # Should we raise or continue at this point ??
示例#2
0
class SessionManagement(Process):
	
	def __init__(self, aps_instance, queue, queue2, queue_sync, logging_queue):
		Process.__init__(self)
		
		self.aps_instance = aps_instance
		self.queue = queue
		self.queue2 = queue2
		self.queue_sync = queue_sync
		self.logging_queue = logging_queue
		
		self.synchronizer = SingletonSynchronizer()
		self.synchronizer.backup()
		self.looping = True
		
		self.current_session_id = multiprocessing.Array("c", 30)
	
	
	def run(self):
		try:
			self.main()
		except Exception, err:
			from ovd.Config import Config
			import os
			import time
			import traceback
			try:
				f = open("%s-crash-%d.txt"%(Config.log_file, os.getpid()), "a")
				f.write("%s - Unhandled exception: \n"%(time.asctime()))
				f.write(traceback.format_exc())
				f.close()
			except IOError, err:
				pass
			
			raise err # Should we raise or continue at this point ??
class SessionManagement(Process):
	def __init__(self, aps_instance, queue, queue2, queue_sync, logging_queue):
		Process.__init__(self)
		
		self.aps_instance = aps_instance
		self.queue = queue
		self.queue2 = queue2
		self.queue_sync = queue_sync
		self.logging_queue = logging_queue

		self.synchronizer = SingletonSynchronizer()
		self.synchronizer.backup()

	def run(self):
		self.synchronizer.restore()
		Logger._instance.setQueue(self.logging_queue, False)
		loop = True

		Platform.System.prepareForSessionActions()
		
		# Prevent the process to be stop by a keyboard interruption
		def quit(machin, truc):
			global loop
			loop = False
		signal.signal(signal.SIGINT, signal.SIG_IGN)
		signal.signal(signal.SIGTERM, quit)
		
		Logger.debug("Starting SessionManager process")
		while loop:
			try:
				(request, obj) = self.queue2.get_nowait()
			except Queue.Empty:
				try:
					(request, obj) = self.queue.get(True, 4)
				except Queue.Empty, e:
					continue
				except IOError, e:
					if e.errno == 4:
						break
					else:
						raise e
			
			if request == "create":
				session = obj
				self.create_session(session)
				session.locked = False
				self.queue_sync.put(session)
			elif request == "destroy":
				session = obj
				self.destroy_session(session)
				session.locked = False
				self.queue_sync.put(session)
			elif request == "logoff":
				user = obj
				self.destroy_user(user)
			elif request == "manage_new":
				session = obj
				self.manage_new_session(session)
				session.locked = False
				self.queue_sync.put(session)
示例#4
0
class SessionManagement(Process):
    def __init__(self, aps_instance, queue, queue2, queue_sync, logging_queue):
        Process.__init__(self)

        self.aps_instance = aps_instance
        self.queue = queue
        self.queue2 = queue2
        self.queue_sync = queue_sync
        self.logging_queue = logging_queue

        self.synchronizer = SingletonSynchronizer()
        self.synchronizer.backup()

    def run(self):
        self.synchronizer.restore()
        Logger._instance.setQueue(self.logging_queue, False)
        loop = True

        Platform.System.prepareForSessionActions()

        # Prevent the process to be stop by a keyboard interruption
        def quit(machin, truc):
            global loop
            loop = False

        signal.signal(signal.SIGINT, signal.SIG_IGN)
        signal.signal(signal.SIGTERM, quit)

        Logger.debug("Starting SessionManager process")
        while loop:
            try:
                (request, obj) = self.queue2.get_nowait()
            except Queue.Empty:
                try:
                    (request, obj) = self.queue.get(True, 4)
                except Queue.Empty, e:
                    continue
                except IOError, e:
                    if e.errno == 4:
                        break
                    else:
                        raise e

            if request == "create":
                session = obj
                self.create_session(session)
                session.locked = False
                self.queue_sync.put(session)
            elif request == "destroy":
                session = obj
                self.destroy_session(session)
                session.locked = False
                self.queue_sync.put(session)
            elif request == "logoff":
                user = obj
                self.destroy_user(user)
            elif request == "manage_new":
                session = obj
                self.manage_new_session(session)
                session.locked = False
                self.queue_sync.put(session)