|
@@ -8,8 +8,8 @@ logging.basicConfig(filename='/var/www/html/data/log/qreader.log', level=logging
|
|
log = logging.getLogger('reader')
|
|
log = logging.getLogger('reader')
|
|
|
|
|
|
class MyTestCase(unittest.TestCase):
|
|
class MyTestCase(unittest.TestCase):
|
|
- __redis_host = '192.168.3.104'
|
|
|
|
- # __redis_host = '192.168.3.46'
|
|
|
|
|
|
+ # __redis_host = '192.168.3.104'
|
|
|
|
+ __redis_host = '192.168.3.46'
|
|
def test_something(self):
|
|
def test_something(self):
|
|
self.assertEqual(True, False) # add assertion here
|
|
self.assertEqual(True, False) # add assertion here
|
|
|
|
|
|
@@ -114,6 +114,26 @@ class MyTestCase(unittest.TestCase):
|
|
x = int(time.time())
|
|
x = int(time.time())
|
|
print(x)
|
|
print(x)
|
|
|
|
|
|
|
|
+ def test_rpop(self):
|
|
|
|
+ import redis
|
|
|
|
+ import json
|
|
|
|
+
|
|
|
|
+ pool = redis.ConnectionPool(host=self.__redis_host, port=6379, db=0)
|
|
|
|
+ r = redis.Redis(connection_pool=pool)
|
|
|
|
+ item = r.rpop('REFILL_MONITOR_QUEUE')
|
|
|
|
+
|
|
|
|
+ if item is None:
|
|
|
|
+ print('hello')
|
|
|
|
+ else:
|
|
|
|
+ try:
|
|
|
|
+ val = json.loads(item)
|
|
|
|
+ method = val['method']
|
|
|
|
+ params = val['params']
|
|
|
|
+ print(method,params)
|
|
|
|
+ except Exception as ex:
|
|
|
|
+ log.error(ex)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|