Skip to content

Commit

Permalink
Runtime error when websocket is missing from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Dec 13, 2015
1 parent 1e0da30 commit 2ba8a89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion engineio/async_eventlet.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import importlib
import sys

from eventlet.websocket import WebSocketWSGI as _WebSocketWSGI


class WebSocketWSGI(_WebSocketWSGI): # pragma: no cover
def __call__(self, environ, start_response):
if 'eventlet.input' not in environ:
raise RuntimeError('You need to use the eventlet server. '
'See the Deployment section of the '
'documentation for more information.')
super(WebSocketWSGI, self).__call__(environ, start_response)


async = {
'threading': importlib.import_module('eventlet.green.threading'),
'thread_class': 'Thread',
'queue': importlib.import_module('eventlet.queue'),
'queue_class': 'Queue',
'websocket': importlib.import_module('eventlet.websocket'),
'websocket': sys.modules[__name__],
'websocket_class': 'WebSocketWSGI'
}
4 changes: 2 additions & 2 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def test_async_mode_eventlet(self):

from eventlet.green import threading
from eventlet import queue
from eventlet import websocket
from engineio import async_eventlet

self.assertEqual(s.async['threading'], threading)
self.assertEqual(s.async['thread_class'], 'Thread')
self.assertEqual(s.async['queue'], queue)
self.assertEqual(s.async['queue_class'], 'Queue')
self.assertEqual(s.async['websocket'], websocket)
self.assertEqual(s.async['websocket'], async_eventlet)
self.assertEqual(s.async['websocket_class'], 'WebSocketWSGI')

@mock.patch('importlib.import_module', side_effect=_mock_import)
Expand Down

0 comments on commit 2ba8a89

Please sign in to comment.