Skip to content

Commit

Permalink
Remove context manager for containers
Browse files Browse the repository at this point in the history
The context manager only disconnected the Redis connection on exit.
This was dangerous because we can pass in / reuse a Redis client when
instantiating the container.
  • Loading branch information
brainix committed Nov 5, 2016
1 parent 5e90e3a commit e2a4ea7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 85 deletions.
21 changes: 1 addition & 20 deletions pottery/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,26 +154,7 @@ def clear(self):



class _ContextManaged(metaclass=abc.ABCMeta):
@abc.abstractproperty
def redis(self):
'Redis client.'

@abc.abstractmethod
def __del__(self):
...

def __enter__(self):
return self

def __exit__(self, exc_type, exc_value, traceback):
self.__del__() # We can't do del self because we still need a
# referense to self for the next line...
self.redis.connection_pool.disconnect()



class Base(_Common, _ContextManaged, _Clearable, Pipelined):
class Base(_Common, _Clearable, Pipelined):
...


Expand Down
65 changes: 0 additions & 65 deletions tests/test_context_manager.py

This file was deleted.

0 comments on commit e2a4ea7

Please sign in to comment.