Python redis.ConnectionError() Examples
The following are 30
code examples of redis.ConnectionError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
redis
, or try the search function
.
Example #1
Source File: stream.py From ztag with Apache License 2.0 | 8 votes |
def push(self, noretry=False): import redis if self.queued == 0: return try: p = self.redis.pipeline() for r in self.records: p.rpush(self.queue, r) for r in self.certificates: p.rpush(self.CERTIFICATES_QUEUE, r) p.execute() self.queued = 0 self.records = [] self.certificates = [] self.retries = 0 except redis.ConnectionError as e: time.sleep(1.0) self.retries += 1 if self.retries > self.MAX_RETRIES or noretry: msg = "redis connection error: %s" % str(e) self.logger.fatal(msg) self.redis = None
Example #2
Source File: processtrigger.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #3
Source File: sender.py From AdslProxy with MIT License | 6 votes |
def remove_proxy(self): """ 移除代理 :return: None """ logger.info(f'Removing {CLIENT_NAME}...') try: # 由于拨号就会中断连接,所以每次都要重新建立连接 if hasattr(self, 'redis') and self.redis: self.redis.close() self.redis = RedisClient() self.redis.remove(CLIENT_NAME) logger.info(f'Removed {CLIENT_NAME} successfully') return True except redis.ConnectionError: logger.info(f'Remove {CLIENT_NAME} failed')
Example #4
Source File: playbackcontrol.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #5
Source File: slewlimiter.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #6
Source File: recordsignal.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #7
Source File: recordcontrol.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #8
Source File: playbacksignal.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument('-i', '--inifile', default=os.path.join(path, name + '.ini'), help='name of the configuration file') args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError('cannot connect to Redis server') # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #9
Source File: inputosc.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #10
Source File: launchpad.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #11
Source File: plottrigger.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #12
Source File: compressor.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): """Initialize the module This adds a set of global variables """ global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print("LOCALS: " + ", ".join(locals().keys()))
Example #13
Source File: vumeter.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #14
Source File: quantizer.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #15
Source File: outputgpio.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #16
Source File: lsl2ft.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #17
Source File: generateclock.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): """Initialize the module This adds a set of global variables """ global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print("LOCALS: " + ", ".join(locals().keys()))
Example #18
Source File: historycontrol.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #19
Source File: volcabeats.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #20
Source File: plotcontrol.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r)
Example #21
Source File: endorphines.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): """Initialize the module This adds a set of global variables """ global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print("LOCALS: " + ", ".join(locals().keys()))
Example #22
Source File: volcakeys.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #23
Source File: outputosc.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #24
Source File: recordtrigger.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #25
Source File: outputmqtt.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #26
Source File: outputcvgate.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #27
Source File: clockdivider.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #28
Source File: postprocessing.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))
Example #29
Source File: test_django_project_views.py From product-database with MIT License | 6 votes |
def test_failed_redis_connection(self, monkeypatch): """redis not available""" def raise_exception(): raise redis.ConnectionError() monkeypatch.setattr(app, "AsyncResult", lambda task_id: raise_exception()) url = reverse(self.URL_NAME, kwargs={"task_id": "mock_task_id"}) request = RequestFactory().get(url) request.META["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest" # AJAX request request.user = User.objects.create(username="testuser", is_superuser=False, is_staff=False) response = views.task_status_ajax(request, "mock_task_id") assert response.status_code == 200, "Should be callable" assert json.loads(response.content.decode()) == { "state": "failed", "error_message": "A server process (redis) is not running, please contact the administrator" }
Example #30
Source File: inputlsl.py From eegsynth with GNU General Public License v3.0 | 6 votes |
def _setup(): '''Initialize the module This adds a set of global variables ''' global parser, args, config, r, response, patch parser = argparse.ArgumentParser() parser.add_argument("-i", "--inifile", default=os.path.join(path, name + '.ini'), help="name of the configuration file") args = parser.parse_args() config = configparser.ConfigParser(inline_comment_prefixes=('#', ';')) config.read(args.inifile) try: r = redis.StrictRedis(host=config.get('redis', 'hostname'), port=config.getint('redis', 'port'), db=0, charset='utf-8', decode_responses=True) response = r.client_list() except redis.ConnectionError: raise RuntimeError("cannot connect to Redis server") # combine the patching from the configuration file and Redis patch = EEGsynth.patch(config, r) # there should not be any local variables in this function, they should all be global if len(locals()): print('LOCALS: ' + ', '.join(locals().keys()))