[Lyntin-cvs] CVS: lyntinng engine.py,1.81,1.82 test.py,1.8,NONE threadmanager.py,1.10,NONE
Brought to you by:
glasssnake,
willhelm
From: will g. <wil...@us...> - 2003-01-29 18:35:45
|
Update of /cvsroot/lyntin/lyntinng In directory sc8-pr-cvs1:/tmp/cvs-serv25327 Modified Files: engine.py Removed Files: test.py threadmanager.py Log Message: Moved the test.py file to errata/unittest.py. Removed the threadmanager.py and folded the functionality into the engine.py. Index: engine.py =================================================================== RCS file: /cvsroot/lyntin/lyntinng/engine.py,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -r1.81 -r1.82 *** engine.py 24 Jan 2003 03:01:04 -0000 1.81 --- engine.py 29 Jan 2003 18:35:40 -0000 1.82 *************** *** 11,15 **** that do work in Lyntin as well as encapsulates the event queue, event handling methods, and some of the other singleton managers such as ! the HelpManager, the ThreadManager, and the CommandManager. Engine also holds hooks to the various event types. Events will call --- 11,15 ---- that do work in Lyntin as well as encapsulates the event queue, event handling methods, and some of the other singleton managers such as ! the HelpManager and the CommandManager. Engine also holds hooks to the various event types. Events will call *************** *** 17,20 **** --- 17,24 ---- interface without changing the Lyntin internals. + The engine also holds a list of registered threads. This helps in + diagnostics. Use the methods in exported to handle spinning off + threads. + The Engine class is a singleton and the reference to it is stored in "engine.myengine". However, you should use the exported module *************** *** 22,28 **** """ import Queue, thread, sys import session, lyntin, utils, event, argparser ! import exported, hooks, helpmanager, history, threadmanager, commandmanager # this is the singleton reference to the Engine instance. --- 26,33 ---- """ import Queue, thread, sys + from threading import Thread import session, lyntin, utils, event, argparser ! import exported, hooks, helpmanager, history, commandmanager # this is the singleton reference to the Engine instance. *************** *** 56,63 **** self._managers = {} - # the thread manager manages all the threads in the engine. - # there is only one thread manager - self._managers["thread"] = threadmanager.ThreadManager() - # the help manager manages all the help content in a hierarchical # structure. --- 61,64 ---- *************** *** 79,82 **** --- 80,86 ---- self._tick = 0 + # list of registered threads + self._threads = [] + # counts the total number of events processed--for diagnostics self._num_events_processed = 0 *************** *** 125,129 **** @type func: function """ ! self.getManager("thread").startThread(name, func) def checkthreads(self): --- 129,141 ---- @type func: function """ ! # clean up the list of threads that we maintain first ! self._threadCleanup() ! ! # create and initialize the new thread and stick it in our list ! t = Thread(None, func) ! t.setDaemon(1) ! t.setName(name) ! t.start() ! self._threads.append(t) def checkthreads(self): *************** *** 136,140 **** @rtype: list of strings """ ! return self.getManager("thread").checkThreadsStatus() --- 148,168 ---- @rtype: list of strings """ ! data = [] ! for mem in self._threads: ! data.append(" %s %d" % (mem.getName(), mem.isAlive())) ! ! return data ! ! def _threadCleanup(self): ! """ ! Removes threads which have ended. ! """ ! removeme = [] ! for i in range(len(self._threads)): ! if self._threads[i].isAlive() == 0: ! removeme.append(self._threads[i]) ! ! for mem in removeme: ! self._threads.remove(mem) *************** *** 325,340 **** return ses - def isUniqueSessionName(self, name): - """ - Returns whether a session of that name already exists. - - @param name: the session name to check - @type name: string - - @return: 1 if the name is unique; 0 if not - @rtype: boolean - """ - return not self._sessions.has_key(name) - def registerSession(self, session, name): """ --- 353,356 ---- *************** *** 645,649 **** @rtype: boolean """ - # FIXME - this shouldn't silently fail if self._managers.has_key(name): del self._managers[name] --- 661,664 ---- *************** *** 678,687 **** @rtype: list of strings """ - data = [] # call session.getStatus() and get status from it too ! temp = ses.getStatus() ! ! for mem in temp: ! data.append(mem) # loop through our managers and get status from them --- 693,698 ---- @rtype: list of strings """ # call session.getStatus() and get status from it too ! data = ses.getStatus() # loop through our managers and get status from them --- test.py DELETED --- --- threadmanager.py DELETED --- |