Changeset 247:12a62baf908f
- Timestamp:
- 06/12/12 18:30:23 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/mlx.py
r182 r247 7 7 import os 8 8 import sys 9 10 #-------------------------------------------------------------------------------------- 11 12 instance = None 9 13 10 14 #-------------------------------------------------------------------------------------- … … 24 28 def restart(args = []): 25 29 """Restart the program with the given arguments.""" 26 print "Restarting with args", args30 #print "Restarting with args", args 27 31 programPath = os.path.join(os.path.dirname(sys.argv[0]), 28 32 "runmlx.exe" if os.name=="nt" else "runmlx.sh") … … 38 42 args = [programPath] + args 39 43 44 instance.close() 40 45 os.execv(programPath, args) 41 46 … … 46 51 from singleton import SingleInstance, raiseCallbackWrapper 47 52 53 global instance 48 54 instance = SingleInstance("mlx", raiseCallbackWrapper) 49 55 if not instance: return -
src/mlx/singleton.py
r182 r247 95 95 self._notifySingleton() 96 96 97 def close(self): 98 """Close the instance by closing the mutex.""" 99 if self._mutex: 100 win32api.CloseHandle(self._mutex) 101 self._mutex = None 102 97 103 def _getPipeName(self): 98 104 """Get the name of the pipe to be used for communication.""" … … 127 133 def __del__(self): 128 134 """Destroy the object.""" 129 if self._mutex:130 win32api.CloseHandle(self._mutex)135 self.close() 136 131 137 #---------------------------------------------------------------------------- 132 138 … … 196 202 else: 197 203 self._notifySingleton() 204 205 def close(self): 206 """Close the instance by closing the mutex.""" 207 if self._isSingle: 208 if self._lockFile: 209 self._lockFile.close() 210 self._lockFile = None 211 try: 212 os.remove(self._lockName) 213 except: 214 pass 215 try: 216 os.remove(self._socketName) 217 except: 218 pass 219 198 220 199 221 def _startSocketServer(self, raiseCallback): … … 224 246 def __del__(self): 225 247 """Destroy the object.""" 226 if self._isSingle: 227 self._lockFile.close() 228 try: 229 os.remove(self._lockName) 230 except: 231 pass 232 try: 233 os.remove(self._socketName) 234 except: 235 pass 248 self.close() 236 249 237 250 #----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.