File: async_eventlet.py

package info (click to toggle)
python-engineio 3.0.0%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 468 kB
  • sloc: python: 4,688; makefile: 15
file content (30 lines) | stat: -rw-r--r-- 1,023 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import importlib
import sys

from eventlet import sleep
from eventlet.websocket import WebSocketWSGI as _WebSocketWSGI


class WebSocketWSGI(_WebSocketWSGI):
    def __init__(self, *args, **kwargs):
        super(WebSocketWSGI, self).__init__(*args, **kwargs)
        self._sock = None

    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.')
        self._sock = environ['eventlet.input'].get_socket()
        return 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': sys.modules[__name__],
    'websocket_class': 'WebSocketWSGI',
    'sleep': sleep
}