Skip to content
Browse files

Merge pull request #17 from bufferx/bugfix-stream-maybe-none

Bugfix: Check stream when close socket
  • Loading branch information...
2 parents 7053d1f + 1fe8304 commit d84973e170333cac8a6f4b791e6f072d4b2387bc @paolo-losi committed Jan 10, 2014
Showing with 8 additions and 3 deletions.
  1. +8 −3 stormed/connection.py
View
11 stormed/connection.py
@@ -131,9 +131,14 @@ def _add_ioloop_callback(self, callback):
self.io_loop._callbacks.add(callback)
def close_stream(self):
- self.status = status.CLOSED
- self.stream.close()
- self.stream = None
+ if self.stream is None:
+ return
+
+ try:
+ self.stream.close()
+ finally:
+ self.status = status.CLOSED
+ self.stream = None
def on_closed_stream(self):
if self.status != status.CLOSED:

0 comments on commit d84973e

Please sign in to comment.
Something went wrong with that request. Please try again.