[Zodb-checkins] SVN: ZODB/trunk/src/ZEO/zrpc/trigger.py Merge rev 30900 from 3.4 branch.

Tim Peters tim.one at comcast.net
Thu Jun 23 21:24:45 EDT 2005


Log message for revision 30901:
  Merge rev 30900 from 3.4 branch.
  
  _triggerbase:  Make new-style class, for better debugability.
  
  Windows trigger.__init__:  Simplify more.  The trigger can connect
  after the other end has done  bind() and listen(); no need to wait
  for an accept() too, and so no need to fiddle with blocking/
  non-blocking or "expected" socket.error's either.
  

Changed:
  U   ZODB/trunk/src/ZEO/zrpc/trigger.py

-=-
Modified: ZODB/trunk/src/ZEO/zrpc/trigger.py
===================================================================
--- ZODB/trunk/src/ZEO/zrpc/trigger.py	2005-06-24 01:23:03 UTC (rev 30900)
+++ ZODB/trunk/src/ZEO/zrpc/trigger.py	2005-06-24 01:24:45 UTC (rev 30901)
@@ -52,7 +52,7 @@
 # new data onto a channel's outgoing data queue at the same time that
 # the main thread is trying to remove some]
 
-class _triggerbase:
+class _triggerbase(object):
     """OS-independent base class for OS-dependent trigger class."""
 
     kind = None  # subclass must set to "pipe" or "loopback"; used by repr
@@ -168,23 +168,10 @@
 
             # Specifying port 0 tells Windows to pick a port for us.
             a.bind(("127.0.0.1", 0))
-            connect_address = a.getsockname()  # actual (host, port) pair
+            connect_address = a.getsockname()  # assigned (host, port) pair
             a.listen(1)
-
-            # Before connecting, set w non-blocking, because the connect can't
-            # succeed before we call a.accept() -- while a.accept() can't
-            # succeed before we try to connect.  Maybe it would be clearer
-            # to spin off a thread to do this, but that's much more expensive
-            # than this hack.
-            w.setblocking(0)
-            try:
-                w.connect(connect_address)
-            except socket.error:
-                # Expected exception, since a.accept() hasn't been called
-                # yet.
-                pass
-            w.setblocking(1)
-            r, addr = a.accept()  # r becomes asyncore's socket
+            w.connect(connect_address)
+            r, addr = a.accept()  # r becomes asyncore's (self.)socket
             a.close()
             asyncore.dispatcher.__init__(self, r)
 



More information about the Zodb-checkins mailing list