Skip to content

Commit

Permalink
Revert "Clean global variable"
Browse files Browse the repository at this point in the history
  • Loading branch information
EricSoroos authored Jan 18, 2022
1 parent 1565a9a commit eca734a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ckan/lib/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

log = logging.getLogger(__name__)

# Redis connection pool. Do not use this directly, use ``connect_to_redis``
# instead.
_connection_pool = None


def connect_to_redis():
u'''
Expand All @@ -29,9 +33,11 @@ def connect_to_redis():
.. seealso:: :py:func:`is_redis_available`
'''
url = config.get_value('ckan.redis.url')
log.debug(u'Using Redis at {}'.format(url))
_connection_pool = ConnectionPool.from_url(url)
global _connection_pool
if _connection_pool is None:
url = config.get_value('ckan.redis.url')
log.debug(u'Using Redis at {}'.format(url))
_connection_pool = ConnectionPool.from_url(url)
return Redis(connection_pool=_connection_pool)


Expand Down

0 comments on commit eca734a

Please sign in to comment.