title: Connection pool to external services (redis) in pyramid
body: <p>I need to create a global connection pool to redis <code>redis.BlockingConnectionPool</code> what would be the best way to initialize this and where to do it. So I can always have access to to them and those connections can always be open for very fast access. I found two approaches:</p>
  <ol>
  <li>Using config registry as such</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>#__init__.py
  def make_wsgi_app(settings, **kwargs):
       ...
      config = Configurator(settings=settings)
      config.registry.connection_pool = redis.BlockingConnectionPool()
  </code></pre>
  <ol start="2">
  <li>Using global module constants</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>#myredis.py
  RedisConnectionPool = BlockingConnectionPool()
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>#__init__.py
  import myredis
  def make_wsgi_app(settings, **kwargs):
       ...
  </code></pre>
  <p>I am new to pyramid and don't really know how this pool would be shared in each case and how they differ. Any insight would be greatly appreciated.</p>
  <p>Just to be clear redis will NOT be used as session backend etc. It would be used as a kind of IPC. Where jobs would be scheduled, and where their result would be stored.</p>