Skip to content

Commit

Permalink
modified | modified BaseStructure class to use lazy import on urandom…
Browse files Browse the repository at this point in the history
… and SeCo library to resolve the dependency issue, modified HyperLogLog to do the same with redis ResponseError.
  • Loading branch information
copyrighthero committed Mar 19, 2018
1 parent 1cd6e99 commit 04b4844
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 2 additions & 3 deletions redistr/BaseStructure.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Author: Hansheng Zhao <zhaohans@msu.edu> (https://www.zhs.me)

from os import urandom


class BaseStructure(object):
""" Redis interfaces base structure """
Expand All @@ -18,7 +16,8 @@ def __init__(self, redis, token = None):
:param redis: redis, the redis instance
:param token: mixed, the access token
"""
# import SeCo serializer
# import urandom and SeCo
from os import urandom
from seco import SeCo
# set the default type
self._type = b'none'
Expand Down
9 changes: 2 additions & 7 deletions redistr/HyperLogLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

from .BaseStructure import BaseStructure

try:
# attempts to import redis error
from redis import ResponseError
except ImportError:
# use general exception instead
ResponseError = Exception


__all__ = ('HyperLogLog', )

Expand All @@ -23,6 +16,8 @@ def __init__(self, redis, token = None):
:param redis: redis, the instance
:param token: mixed, access token
"""
# import redis ResponseError
from redis import ResponseError
super(HyperLogLog, self).__init__(redis, token)
# set the default data type
self._type = b'string'
Expand Down

0 comments on commit 04b4844

Please sign in to comment.