[py-svn] r36343 - in py/dist/py: documentation execnet

hpk at codespeak.net hpk at codespeak.net
Tue Jan 9 13:12:31 CET 2007


Author: hpk
Date: Tue Jan  9 13:12:23 2007
New Revision: 36343

Modified:
   py/dist/py/documentation/TODO.txt
   py/dist/py/execnet/channel.py
   py/dist/py/execnet/gateway.py
   py/dist/py/execnet/register.py
Log:
streamline gateway exported methods,
move the internal helper methods to "_" names. 


Modified: py/dist/py/documentation/TODO.txt
==============================================================================
--- py/dist/py/documentation/TODO.txt	(original)
+++ py/dist/py/documentation/TODO.txt	Tue Jan  9 13:12:23 2007
@@ -7,7 +7,7 @@
 streamline exported API 
 -------------------------------------
 
-* move not-to-be-exported Gateway() methods to _ - methods. 
+* (hpk, should be done) move not-to-be-exported Gateway() methods to _ - methods. 
 * docstrings  for all exported API
 
 packaging

Modified: py/dist/py/execnet/channel.py
==============================================================================
--- py/dist/py/execnet/channel.py	(original)
+++ py/dist/py/execnet/channel.py	Tue Jan  9 13:12:23 2007
@@ -69,7 +69,7 @@
     def __del__(self):
         if self.gateway is None:   # can be None in tests
             return
-        self.gateway.trace("Channel(%d).__del__" % self.id)
+        self.gateway._trace("Channel(%d).__del__" % self.id)
         # no multithreading issues here, because we have the last ref to 'self'
         if self._closed:
             # state transition "closed" --> "deleted"

Modified: py/dist/py/execnet/gateway.py
==============================================================================
--- py/dist/py/execnet/gateway.py	(original)
+++ py/dist/py/execnet/gateway.py	Tue Jan  9 13:12:23 2007
@@ -50,7 +50,7 @@
                                     sender = self.thread_sender)
 
     def __repr__(self):
-        addr = self.getremoteaddress()
+        addr = self._getremoteaddress()
         if addr:
             addr = '[%s]' % (addr,)
         else:
@@ -63,13 +63,13 @@
         return "<%s%s %s/%s (%d active channels)>" %(
                 self.__class__.__name__, addr, r, s, i)
 
-    def getremoteaddress(self):
+    def _getremoteaddress(self):
         return None
 
 ##    def _local_trystopexec(self):
 ##        self._execpool.shutdown() 
 
-    def trace(self, *args):
+    def _trace(self, *args):
         if debug:
             try:
                 l = "\n".join(args).split(os.linesep)
@@ -82,14 +82,14 @@
             except:
                 traceback.print_exc()
 
-    def traceex(self, excinfo):
+    def _traceex(self, excinfo):
         try:
             l = traceback.format_exception(*excinfo)
             errortext = "".join(l)
         except:
             errortext = '%s: %s' % (excinfo[0].__name__,
                                     excinfo[1])
-        self.trace(errortext)
+        self._trace(errortext)
 
     def thread_receiver(self):
         """ thread to read and handle Messages half-sync-half-async. """
@@ -98,19 +98,19 @@
             while 1:
                 try:
                     msg = Message.readfrom(self.io)
-                    self.trace("received <- %r" % msg)
+                    self._trace("received <- %r" % msg)
                     msg.received(self)
                 except sysex:
                     raise
                 except EOFError:
                     break
                 except:
-                    self.traceex(exc_info())
+                    self._traceex(exc_info())
                     break 
         finally:
             self._outgoing.put(None)
             self.channelfactory._finished_receiving()
-            self.trace('leaving %r' % threading.currentThread())
+            self._trace('leaving %r' % threading.currentThread())
 
     def thread_sender(self):
         """ thread to send Messages over the wire. """
@@ -125,15 +125,15 @@
                     msg.writeto(self.io)
                 except:
                     excinfo = exc_info()
-                    self.traceex(excinfo)
+                    self._traceex(excinfo)
                     if msg is not None:
                         msg.post_sent(self, excinfo)
                     raise
                 else:
-                    self.trace('sent -> %r' % msg)
+                    self._trace('sent -> %r' % msg)
                     msg.post_sent(self)
         finally:
-            self.trace('leaving %r' % threading.currentThread())
+            self._trace('leaving %r' % threading.currentThread())
 
     def _local_redirect_thread_output(self, outid, errid): 
         l = []
@@ -154,7 +154,7 @@
         from sys import exc_info
         try:
             loc = { 'channel' : channel }
-            self.trace("execution starts:", repr(source)[:50])
+            self._trace("execution starts:", repr(source)[:50])
             close = self._local_redirect_thread_output(outid, errid) 
             try:
                 co = compile(source+'\n', '', 'exec',
@@ -162,7 +162,7 @@
                 exec co in loc
             finally:
                 close() 
-                self.trace("execution finished:", repr(source)[:50])
+                self._trace("execution finished:", repr(source)[:50])
         except (KeyboardInterrupt, SystemExit):
             raise
         except:
@@ -170,12 +170,12 @@
             l = traceback.format_exception(*excinfo)
             errortext = "".join(l)
             channel.close(errortext)
-            self.trace(errortext)
+            self._trace(errortext)
         else:
             channel.close()
 
     def _local_schedulexec(self, channel, sourcetask): 
-        self.trace("dispatching exec")
+        self._trace("dispatching exec")
         self._execpool.dispatch(self.thread_executor, channel, sourcetask) 
 
     def _newredirectchannelid(self, callback): 
@@ -264,7 +264,7 @@
 ##                if not self.pool.getstarted('sender'): 
 ##                    raise IOError("sender thread not alive anymore!") 
 ##                self._outgoing.put(None)
-##                self.trace("exit procedure triggered, pid %d " % (os.getpid(),))
+##                self._trace("exit procedure triggered, pid %d " % (os.getpid(),))
 ##                _gateways.remove(self) 
 ##        finally:
 ##            self._exitlock.release()
@@ -280,12 +280,12 @@
         current = threading.currentThread()
         for x in self.pool.getstarted(): 
             if x != current: 
-                self.trace("joining %s" % x)
+                self._trace("joining %s" % x)
                 x.join()
-        self.trace("joining sender/reciver threads finished, current %r" % current) 
+        self._trace("joining sender/reciver threads finished, current %r" % current) 
         if joinexec: 
             self._execpool.join()
-            self.trace("joining execution threads finished, current %r" % current) 
+            self._trace("joining execution threads finished, current %r" % current) 
 
 def getid(gw, cache={}):
     name = gw.__class__.__name__

Modified: py/dist/py/execnet/register.py
==============================================================================
--- py/dist/py/execnet/register.py	(original)
+++ py/dist/py/execnet/register.py	Tue Jan  9 13:12:23 2007
@@ -44,7 +44,7 @@
         bootstrap += [getsource(x) for x in startup_modules]
         bootstrap += [io.server_stmt, "Gateway(io=io, startcount=2).join(joinexec=False)",]
         source = "\n".join(bootstrap)
-        self.trace("sending gateway bootstrap code")
+        self._trace("sending gateway bootstrap code")
         io.write('%r\n' % source)
 
 class PopenCmdGateway(InstallableGateway):
@@ -62,12 +62,12 @@
 ##            self._pidchannel.waitclose(timeout=0.5)
 ##            pid = self._pidchannel.receive()
 ##        except IOError:
-##            self.trace("IOError: could not receive child PID:")
-##            self.traceex(sys.exc_info())
+##            self._trace("IOError: could not receive child PID:")
+##            self._traceex(sys.exc_info())
 ##            pid = None
 ##        super(PopenCmdGateway, self).exit()
 ##        if pid is not None: 
-##            self.trace("waiting for pid %s" % pid)
+##            self._trace("waiting for pid %s" % pid)
 ##            try:
 ##                os.waitpid(pid, 0)
 ##            except KeyboardInterrupt: 
@@ -75,7 +75,7 @@
 ##                    os.kill(pid, 15) 
 ##                raise
 ##            except OSError, e:
-##                self.trace("child process %s already dead? error:%s" %
+##                self._trace("child process %s already dead? error:%s" %
 ##                           (pid, str(e)))
 
 class PopenGateway(PopenCmdGateway):
@@ -137,7 +137,7 @@
         io = inputoutput.SocketIO(sock)
         InstallableGateway.__init__(self, io=io)
 
-    def getremoteaddress(self):
+    def _getremoteaddress(self):
         return '%s:%d' % (self.host, self.port)
 
     def remote_install(cls, gateway, hostport=None): 
@@ -162,7 +162,7 @@
         hostname, (realhost, realport) = channel.receive() 
         if hostport is None: 
             realhost = hostname 
-        #gateway.trace("remote_install received" 
+        #gateway._trace("remote_install received" 
         #              "port=%r, hostname = %r" %(realport, hostname))
         return py.execnet.SocketGateway(realhost, realport) 
     remote_install = classmethod(remote_install)
@@ -181,7 +181,7 @@
         cmdline.insert(0, cmd) 
         super(SshGateway, self).__init__(' '.join(cmdline))
 
-    def getremoteaddress(self):
+    def _getremoteaddress(self):
         return self.sshaddress
 
 class ExecGateway(PopenGateway):


More information about the py-svn mailing list