You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1023B

  1. import importlib
  2. import sys
  3. from eventlet import sleep
  4. from eventlet.websocket import WebSocketWSGI as _WebSocketWSGI
  5. class WebSocketWSGI(_WebSocketWSGI):
  6. def __init__(self, *args, **kwargs):
  7. super(WebSocketWSGI, self).__init__(*args, **kwargs)
  8. self._sock = None
  9. def __call__(self, environ, start_response):
  10. if 'eventlet.input' not in environ:
  11. raise RuntimeError('You need to use the eventlet server. '
  12. 'See the Deployment section of the '
  13. 'documentation for more information.')
  14. self._sock = environ['eventlet.input'].get_socket()
  15. return super(WebSocketWSGI, self).__call__(environ, start_response)
  16. _async = {
  17. 'threading': importlib.import_module('eventlet.green.threading'),
  18. 'thread_class': 'Thread',
  19. 'queue': importlib.import_module('eventlet.queue'),
  20. 'queue_class': 'Queue',
  21. 'websocket': sys.modules[__name__],
  22. 'websocket_class': 'WebSocketWSGI',
  23. 'sleep': sleep
  24. }