Changeset 157

Show
Ignore:
Timestamp:
04/10/08 01:10:39 (9 months ago)
Author:
poillubo
Message:

* we can now call PycaWM.quit in a REPL

+ added a check for a broken pipe in the remoteREPL destroy method
+ SystemExit? is catched in the remoteREPL thread, and we really quit the wm when we catch it

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pycawm/plugins/remoteREPL.py

    r146 r157  
    3939from keyword import kwlist 
    4040from re import match as re_match 
     41from Xlib import error 
    4142 
    4243from pycawm.hookmanager import add_pre_hook, remove_pre_hook 
     
    7374    def destroy(self): 
    7475        if self.sock is not None: 
    75             self.cleanup(self.wm) 
     76            try: 
     77                self.cleanup(self.wm) 
     78            # watch for broken pipe (if the client socket is already closed) 
     79            except socket.error: 
     80                pass 
    7681        self.server_socket.close() 
    7782        try: 
     
    144149    def runcode(self, code): 
    145150        with self.wm.event_lock: 
    146             InteractiveConsole.runcode(self, code) 
     151            try: 
     152                InteractiveConsole.runcode(self, code) 
     153            except SystemExit, exc: 
     154                # we are not in the main thread here 
     155                # so we catch any attempt to quit PycaWM 
     156                # and really make it quit by calling os._exit 
     157                os._exit(exc.code) 
    147158            self.wm.display.sync() 
    148159