Skip to content

Commit

Permalink
no ConnectionError raised any more
Browse files Browse the repository at this point in the history
  • Loading branch information
thefab committed Jun 3, 2015
1 parent 73d516a commit f2690d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import errno
import socket
from tornadis.connection import Connection
from tornadis.exceptions import ConnectionError
from tornadis.utils import format_args_in_redis_protocol
from support import test_redis_or_raise_skiptest
import hiredis
Expand Down Expand Up @@ -215,8 +214,8 @@ def test_write_on_closed_socket(self):
c.write(data1)
# Wait a short moment while the server closes the socket
yield tornado.gen.sleep(.0001)
self.assertRaises(ConnectionError, c._handle_write)
self.assertRaises(ConnectionError, c._handle_read)
c._handle_write()
c._handle_read()
self.assertFalse(c.is_connected())
c.disconnect()

Expand Down
7 changes: 2 additions & 5 deletions tornadis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import tornado.gen
from tornado.util import errno_from_exception
from tornadis.write_buffer import WriteBuffer
from tornadis.exceptions import ConnectionError
from tornadis.state import ConnectionState
from tornado.ioloop import IOLoop
import tornadis
Expand Down Expand Up @@ -184,8 +183,7 @@ def _handle_events(self, fd, event):
if err != 0:
LOG.debug("connecting error in _handle_events")
self.disconnect()
raise ConnectionError("Connect error: %s" %
errno.errorcode[err])
return
self._state.set_connected()
LOG.debug("connected to %s:%i", self.host, self.port)
if not self.is_connected():
Expand Down Expand Up @@ -221,7 +219,7 @@ def _handle_write(self):
break
else:
self.disconnect()
raise ConnectionError("can't write to socket: %s" % e)
return
else:
LOG.debug("%i bytes written to the socket", size)
if size < len(data):
Expand All @@ -246,7 +244,6 @@ def _read(self, size):
return None
else:
self.disconnect()
raise ConnectionError("error during socket.recv: %s" % e)

def write(self, data):
"""Buffers some data to be sent to the host:port in a non blocking way.
Expand Down

0 comments on commit f2690d8

Please sign in to comment.