Commits

Christian Zagrodnick committed cfff76a

Improve stability for Zope 2 port binding. (raised AttributeError occasionally)

Comments (0)

Files changed (2)

 1.1 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Improve stability for Zope 2 port binding. (raised AttributeError
+  occasionally)
 
 
 1.0 (2012-11-03)

src/gocept/selenium/zope2/__init__.py

             time.sleep(0.025)
             for dispatcher in asyncore.socket_map.values():
                 if isinstance(dispatcher, ZServer.HTTPServer.zhttp_server):
-                    self.port = dispatcher.server_port
-                    break
+                    try:
+                        self.port = dispatcher.server_port
+                    except AttributeError:
+                        # Seems to happen when the dispatcher instance has been
+                        # created, but the port wasn't bound, yet. Just ignore
+                        # and wait for the next cycle.
+                        pass
+                    else:
+                        break
 
         # notify ZopeTestCase infrastructure that a ZServer has been started
         Testing.ZopeTestCase.utils._Z2HOST = self.host