Skip to content

Commit

Permalink
corrected logic that selects gevent_uwsgi as async mode
Browse files Browse the repository at this point in the history
Fixes #28
  • Loading branch information
miguelgrinberg committed Sep 1, 2016
1 parent 43fbe9a commit db2fb14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
7 changes: 2 additions & 5 deletions engineio/async_gevent_uwsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import six

import gevent
try:
import uwsgi
_websocket_available = hasattr(uwsgi, 'websocket_handshake')
except ImportError:
_websocket_available = False
import uwsgi
_websocket_available = hasattr(uwsgi, 'websocket_handshake')


class Thread(gevent.Greenlet): # pragma: no cover
Expand Down
14 changes: 2 additions & 12 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,10 @@ def test_async_mode_gevent_uwsgi(self, import_module):
def test_async_mode_gevent_uwsgi_without_uwsgi(self, import_module):
sys.modules['gevent'] = mock.MagicMock()
sys.modules['uwsgi'] = None
s = server.Server(async_mode='gevent_uwsgi')
self.assertEqual(s.async_mode, 'gevent_uwsgi')

from engineio import async_gevent_uwsgi

self.assertEqual(s.async['threading'], async_gevent_uwsgi)
self.assertEqual(s.async['thread_class'], 'Thread')
self.assertEqual(s.async['queue'], 'gevent.queue')
self.assertEqual(s.async['queue_class'], 'JoinableQueue')
self.assertEqual(s.async['websocket'], None)
self.assertEqual(s.async['websocket_class'], None)
self.assertRaises(ValueError, server.Server,
async_mode='gevent_uwsgi')
del sys.modules['gevent']
del sys.modules['uwsgi']
del sys.modules['engineio.async_gevent_uwsgi']

@mock.patch('importlib.import_module', side_effect=_mock_import)
def test_async_mode_gevent_uwsgi_without_websocket(self, import_module):
Expand Down

0 comments on commit db2fb14

Please sign in to comment.