4

我正在WSGIServer使用地址'0.0.0.0'

    from gevent import pywsgi
    from geventwebsocket.handler import WebSocketHandler

    server = pywsgi.WSGIServer(('0.0.0.0', 5002), app, handler_class=WebSocketHandler)

    server.serve_forever()

这会产生错误TypeError: an integer is required (got type bytes)

如果我改变'0.0.0.0'一切'127.0.0.1'工作就好了。

我在 MacOS 10.14.6 上使用 Python 3.8

这是完整的错误

Traceback (most recent call last):   
File "/Users/ronharlev/Documents/MyProject/streaming_server.py", line 174, in run_process
        server.serve_forever()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/baseserver.py", line 367, in serve_forever
        self.start()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/baseserver.py", line 305, in start
        self.init_socket()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/pywsgi.py", line 1491, in init_socket
        self.update_environ()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/pywsgi.py", line 1503, in update_environ
        name = socket.getfqdn(address[0])   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/_socketcommon.py", line 269, in getfqdn
        hostname, aliases, _ = gethostbyaddr(name)   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/_socketcommon.py", line 241, in gethostbyaddr
        return get_hub().resolver.gethostbyaddr(ip_address)   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/resolver/thread.py", line 68, in gethostbyaddr
        return self.pool.apply(_socket.gethostbyaddr, args, kwargs)   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/pool.py", line 159, in apply
        return self.spawn(func, *args, **kwds).get()   
File "src/gevent/event.py", line 268, in gevent._event.AsyncResult.get   
File "src/gevent/event.py", line 296, in gevent._event.AsyncResult.get 
File "src/gevent/event.py", line 286, in gevent._event.AsyncResult.get 
File "src/gevent/event.py", line 266, in gevent._event.AsyncResult._raise_exception   
File "src/gevent/event.py", line 211, in gevent._event.AsyncResult.exc_info.__get__   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/_tblib.py", line 371, in g
        return f(a)   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/_tblib.py", line 432, in load_traceback
        return loads(s)   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/_tblib.py", line 337, in unpickle_traceback
        return ret.as_traceback()   
File "/Users/ronharlev/Documents/MyProject/venv/lib/python3.8/site-packages/gevent/_tblib.py", line 202, in as_traceback
        code = CodeType( TypeError: an integer is required (got type bytes)
4

1 回答 1

5

根据https://github.com/gevent/gevent/issues/1491

gevent 1.4 与 Python 3.8 不兼容。请在 Python 3.8 上使用 gevent >= 1.5a2。这是在 Python 3.8 上运行 gevent 1.4 的(几个)已知问题之一。

于 2020-03-25T02:59:40.860 回答