Changeset 247:12a62baf908f


Ignore:
Timestamp:
06/12/12 18:30:23 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Hopefully fixed the problem of not restarting properly

Location:
src/mlx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/mlx.py

    r182 r247  
    77import os
    88import sys
     9
     10#--------------------------------------------------------------------------------------
     11
     12instance = None
    913
    1014#--------------------------------------------------------------------------------------
     
    2428def restart(args = []):
    2529    """Restart the program with the given arguments."""
    26     print "Restarting with args", args
     30    #print "Restarting with args", args
    2731    programPath = os.path.join(os.path.dirname(sys.argv[0]),
    2832                               "runmlx.exe" if os.name=="nt" else "runmlx.sh")
     
    3842    args = [programPath] + args
    3943
     44    instance.close()
    4045    os.execv(programPath, args)   
    4146
     
    4651    from singleton import SingleInstance, raiseCallbackWrapper
    4752
     53    global instance
    4854    instance = SingleInstance("mlx", raiseCallbackWrapper)
    4955    if not instance: return
  • src/mlx/singleton.py

    r182 r247  
    9595                self._notifySingleton()
    9696
     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
    97103        def _getPipeName(self):
    98104            """Get the name of the pipe to be used for communication."""
     
    127133        def __del__(self):
    128134            """Destroy the object."""
    129             if self._mutex:
    130                 win32api.CloseHandle(self._mutex)
     135            self.close()
     136               
    131137#----------------------------------------------------------------------------
    132138
     
    196202            else:
    197203                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               
    198220
    199221        def _startSocketServer(self, raiseCallback):
     
    224246        def __del__(self):
    225247            """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()
    236249               
    237250#----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.