1
나는 토네이도 웹 소켓 문서 작업에서 안녕하세요 - 세계 예제를 얻으려고합니다. 나는 꽤 토네이도에 익숙하지 않고 완전히 웹 소켓에 익숙하지 않다.토네이도 웹 소켓 ioloop 예외
class EchoWebSocket(tornado.websocket.WebSocketHandler):
def open(self):
print "WebSocket opened"
def on_message(self, message):
self.write_message(u"You said: " + message)
def on_close(self):
print "WebSocket closed"
을 똑바로 문서에서도
var ws = new WebSocket("ws://localhost:6665/websocket");
ws.onopen = function() {
ws.send("Hello, world");
};
ws.onmessage = function (evt) {
alert(evt.data);
};
를 사용하여 자바 스크립트에서 호출 : 나는 바로 문서에서 다음 핸들러를 지정했습니다. 나는 즉시 세 가지 예외 명중 :
[E 111123 17:45:54 iostream:233] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
[E 111123 17:45:54 iostream:221] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 199, in _handle_events
self._handle_read()
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 258, in _handle_read
if self._read_from_buffer():
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 325, in _read_from_buffer
self._consume(loc + delimiter_len))
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
[E 111123 17:45:54 ioloop:281] Exception in I/O handler for fd 4
Traceback (most recent call last):
File "/local/lib/python2.5/site-packages/tornado/ioloop.py", line 269, in start
self._handlers[fd](fd, events)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 199, in _handle_events
self._handle_read()
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 258, in _handle_read
if self._read_from_buffer():
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 325, in _read_from_buffer
self._consume(loc + delimiter_len))
File "/local/lib/python2.5/site-packages/tornado/iostream.py", line 230, in _run_callback
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/stack_context.py", line 173, in wrapped
callback(*args, **kwargs)
File "/local/lib/python2.5/site-packages/tornado/httpserver.py", line 353, in _on_headers
self.request_callback(self._request)
File "/local/lib/python2.5/site-packages/tornado/web.py", line 1182, in __call__
handler = spec.handler_class(self, request, **spec.kwargs)
TypeError: default __new__ takes no parameters
내가 제대로 구문 분석 할 수없는 것을 고백, 나는 tornado.web에 찍어 불안 해요. 내가 뭘 잘못하고 있는지 분명해? 나는 토네이도를 사용하고있다. 1.2.1.
=) 오, 레거시 시스템 사용의 즐거움. 당신이 옳다고 생각합니다. 사용하려고하는 파이썬의 구버전과 제가 사용하려고하는 토네이도의 구버전 둘 다에 의해 엉망이되었습니다. 저는 제 눈을 감추고 싶을 뿐이라고 생각했습니다. 현실을 확인해 주셔서 감사합니다! –