JamesHarrison / openob

The Open Outside Broadcast project for radio contribution links and studio-transmitter links.
158 stars 34 forks source link

Add a redis ping on making a connection to ensure we can talk to it #47

Closed scottgrobinson closed 5 years ago

scottgrobinson commented 5 years ago

Under my tests, we never reached the exception because the connection was made successfully, but never 'checked'. Without this fix, I'd quickly get the following exception on trying to carry out the first action with Redis:

Traceback (most recent call last):
  File "/usr/local/bin/openob", line 81, in <module>
    link_config.set_from_argparse(opts)
  File "/usr/local/lib/python2.7/dist-packages/openob/link_config.py", line 83, in set_from_argparse
    self.set("name", opts.link_name)
  File "/usr/local/lib/python2.7/dist-packages/openob/link_config.py", line 51, in set
    self.redis.set(scoped_key, value)
  File "/usr/lib/python2.7/dist-packages/redis/client.py", line 1072, in set
    return self.execute_command('SET', *pieces)
  File "/usr/lib/python2.7/dist-packages/redis/client.py", line 578, in execute_command
    connection.send_command(*args)
  File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 563, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 538, in send_packed_command
    self.connect()
  File "/usr/lib/python2.7/dist-packages/redis/connection.py", line 442, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 113 connecting to 192.168.10.1:6379. No route to host.