sgsession.ShotgunPool

A wrapper around shotgun_api3 to allow for parallel requests.

The standard Shotgun API uses a connection object that serialized requests. Therefore, efficient usage in a multi-threaded environment is tricker than it could be. Ergo, this module was concieved.

ShotgunPool is a connection pool that creates fresh Shotgun instances when needed, and recycles old ones after use. It proxies attributes and methods to the managed instances. An actual Shotgun instance should never leak out of this object, so even passing around bound methods from this object should be safe.

E.g.:

>>> # Construct and wrap a Shotgun instance.
>>> shotgun = Shotgun(...)
>>> shotgun = ShotgunPool(shotgun)
>>>
>>> # Use it like normal, except in parallel.
>>> shotgun.find('Task', ...)
class sgsession.pool.ShotgunPool(prototype, *args, **kwargs)

Shotgun connection pool.

Parameters:prototype – Shotgun instance to use as a prototype, OR the base_url to be used to construct a prototype.

If passed a base_url, the remaining args and kwargs will be passed to the Shotgun constructor for creation of a prototype.

The config object of the prototype will be shared amoung all Shotgun instances created; changing the settings on one Shotgun instance (or this object) will affect all other instances.