From 4a3320051aac532918b1e0448aad8cc8da615697 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sat, 9 Dec 2017 09:49:49 -0800 Subject: [PATCH] Reraise exceptions in a Py2/Py3 compatible way Fixes #58 --- engineio/asyncio_socket.py | 4 +++- engineio/socket.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engineio/asyncio_socket.py b/engineio/asyncio_socket.py index 84163c61..718f4cb8 100644 --- a/engineio/asyncio_socket.py +++ b/engineio/asyncio_socket.py @@ -1,5 +1,6 @@ import asyncio import six +import sys import time from . import exceptions @@ -76,8 +77,9 @@ async def handle_get_request(self, environ): try: packets = await self.poll() except exceptions.QueueEmpty: + exc = sys.exc_info() await self.close(wait=False) - raise + six.reraise(*exc) return packets async def handle_post_request(self, environ): diff --git a/engineio/socket.py b/engineio/socket.py index dd983a7e..d4ffa67c 100644 --- a/engineio/socket.py +++ b/engineio/socket.py @@ -1,4 +1,5 @@ import six +import sys import time from . import exceptions @@ -91,8 +92,9 @@ def handle_get_request(self, environ, start_response): try: packets = self.poll() except exceptions.QueueEmpty: + exc = sys.exc_info() self.close(wait=False) - raise + six.reraise(*exc) return packets def handle_post_request(self, environ):