Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: maximum recursion depth exceeded #487

Closed
alvion opened this issue Nov 28, 2016 · 3 comments
Closed

Exception: maximum recursion depth exceeded #487

alvion opened this issue Nov 28, 2016 · 3 comments

Comments

@alvion
Copy link

alvion commented Nov 28, 2016

Exception: <type 'exceptions.RuntimeError'>-- maximum recursion depth exceeded


'  File "build/bdist.linux-x86_64/egg/pyVmomi/VmomiSupport.py", line 580, in <lambda>\n    self.f(*(self.args + (obj,) + args), **kwargs)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/VmomiSupport.py", line 386, in _InvokeMethod\n    return self._stub.InvokeMethod(self, info, args)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1364, in InvokeMethod\n    self.ReturnConnection(conn)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1436, in ReturnConnection\n    self._CloseIdleConnections()\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1384, in _CloseIdleConnections\n    i = self.pool.index((conn, lastAccessTime))\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
 '  File "build/bdist.linux-x86_64/egg/pyVmomi/SoapAdapter.py", line 1060, in __getattr__\n    return getattr(self._wrapped, item)\n',
@magianxd
Copy link
Contributor

I have met the same exception. Any ideas on this?

@tianhao64
Copy link
Contributor

@alvion @magianxd How to reproduce this issue?

@alvion
Copy link
Author

alvion commented Jan 3, 2017

This is my fix for you guys reference.

====================


diff --git a/pyVmomi/SoapAdapter.py b/pyVmomi/SoapAdapter.py
index 76b1841..7338c2b 100644
--- a/pyVmomi/SoapAdapter.py
+++ b/pyVmomi/SoapAdapter.py
@@ -1054,10 +1054,10 @@ class _HTTPSConnection(http_client.HTTPSConnection):
          #      dercert = self.sock.getpeercert(False)
          #      # pemcert = ssl.DER_cert_to_PEM_cert(dercert)
 
-   def __getattr__(self, item):
-      if item == 'connect':
-         return self.connect(self._wrapped)
-      return getattr(self._wrapped, item)
+   #def __getattr__(self, item):
+   #   if item == 'connect':
+   #      return self.connect()
+   #   return getattr(self, item)
 
 ## Stand-in for the HTTPSConnection class that will connect to a proxy and
 ## issue a CONNECT command to start an SSL tunnel.
@@ -1281,7 +1281,10 @@ class SoapStubAdapter(SoapStubAdapterBase):
          conn.close()
    else:
       def _CloseConnection(self, conn):
-         conn.close()
+         try:
+            conn.close()
+         except AttributeError:
+             del conn
 
    # Context modifier used to modify the SOAP request.
    # @param func The func that takes in the serialized message and modifies the
@@ -1379,12 +1382,11 @@ class SoapStubAdapter(SoapStubAdapterBase):
       if self.connectionPoolTimeout >= 0:
          currentTime = time.time()
          idleConnections = []
-         for conn, lastAccessTime in self.pool:
-            idleTime = currentTime - lastAccessTime
+         for idx, content in enumerate(self.pool):
+            idleTime = currentTime - content[1]
             if idleTime >= self.connectionPoolTimeout:
-               i = self.pool.index((conn, lastAccessTime))
-               idleConnections = self.pool[i:]
-               self.pool = self.pool[:i]
+               idleConnections = self.pool[idx:]
+               self.pool = self.pool[:idx]
                break
 
          for conn, _ in idleConnections:

====================
The root cause is getattr hits the infinity loop, also I do some improvements on close idle connections.

Thanks,
Alvion

tianhao64 added a commit that referenced this issue Jan 25, 2017
Fix #487: Remove custom __getattr__ in _HTTPSConnection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants