Is pyvmomi service instance thread-safe?
Hi,
I am using SmartConnectNoSSL to connect to my server.
May I use si (service instance) returned in multithreading environment sharing the same instance of si (e.g. may I load metrics from different resources in parallel).
May there be any issues with vSphere API because of the same session parallel calls?
Thanks
Most operations should be safe by reusing the same si, which is the same session/cookie.
But if you are using the property collector (si.content.propertyCollector), then that will be shared among all the clients of si. In that case, you should create/destroy one explicitly:
pc = si.content.propertyCollector.CreatePropertyCollector()
...
pc.Destroy()
There might be other gotchas to using the same session, but I think that is the main one that I noticed.