Пример #1
0
import collections
import string
import struct
import socket

try:
    from hashlib import md5
except ImportError:  #pragma NO COVER
    from md5 import md5

from meinheld import server, patch
from meinheld.common import Continuation, CLIENT_KEY, CONTINUATION_KEY

patch.patch_socket()

import socket


class WebSocketMiddleware(object):
    def __init__(self, app):
        self.app = app

    def _extract_number(self, value):
        out = ""
        spaces = 0
        for char in value:
            if char in string.digits:
                out += char
            elif char == " ":
                spaces += 1
        return int(out) / spaces
Пример #2
0
import collections
import string
import struct
import socket

try:
    from hashlib import md5
except ImportError: #pragma NO COVER
    from md5 import md5

from meinheld import server, patch
from meinheld.common import Continuation, CLIENT_KEY, CONTINUATION_KEY
patch.patch_socket()

import socket

class WebSocketMiddleware(object):

    def __init__(self, app):
        self.app = app

    def _extract_number(self, value):
        out = ""
        spaces = 0
        for char in value:
            if char in string.digits:
                out += char
            elif char == " ":
                spaces += 1
        return int(out) / spaces
    
def post_fork(server, worker):
    from meinheld.patch import patch_socket
    patch_socket()