vmware / vmware/pyvmomi

Global variables of SmartConnect

Open
#634 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

So I have the following codes in a file called vcenter.py:

  5 from pyVim.connect import SmartConnect, Disconnect
  6 import requests
  7 import ssl
  8
  9 requests.packages.urllib3.disable_warnings()
 10 _create_unverified_https_context = ssl._create_unverified_context # pylint: disable=W0212
 11 ssl._create_default_https_context = _create_unverified_https_context # pylint: disable=W0212
 12
 13 class VCenter( object ):
 14    def __init__( self ):
 15    ¦  self.si = SmartConnect( host='vcenter', user='root', pwd='password', port=443 )
 16
 17    def __del__( self ):
 18    ¦  if self.si:
 19    ¦  ¦  Disconnect( self.si )
 20
 21 tmp = VCenter()

When I run the file, it shows the following:

Exception TypeError: "'NoneType' object is not callable" in <bound method VCenter.__del__ of <__main__.VCenter object at 0x7f8ad3399f90>> ignored

Any ideas or workarounds? Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shutdown error from the vcenter.py example, focusing on VCenter.del and the SmartConnect/Disconnect calls. Read the pyVim.connect lifecycle behavior and any nearby cleanup examples; done means the cause is established and a supported workaround or corrective change is clearly identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.