diff options
-rw-r--r-- | ryu/controller/controller.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index 4680f9a5..32d89dd5 100644 --- a/ryu/controller/controller.py +++ b/ryu/controller/controller.py @@ -189,12 +189,19 @@ class Datapath(object): @_deactivate def _send_loop(self): - while self.is_active: - buf = self.send_q.get() - self.socket.sendall(buf) + try: + while self.is_active: + buf = self.send_q.get() + self.socket.sendall(buf) + finally: + q = self.send_q + self.send_q = None + while q.get(): + pass def send(self, buf): - self.send_q.put(buf) + if self.send_q: + self.send_q.put(buf) def set_xid(self, msg): self.xid += 1 |