2
저는 twistd
을 사용하고 있습니다. 연결이 실패 할 경우 LobbyProtocol
의 공장에서 Twisted + wxPython에 부정한 것이 있습니다
def CloseWithCallback(self, callback, *callbackArgs):
def destroyed(event):
event.Skip()
callback(*callbackArgs)
self.Bind(wx.EVT_WINDOW_DESTROY, destroyed)
self.Close()
, 나는 원자로를 정지 : 다음과 같이
class GameClientService(internet.TCPClient):
def __init__(self, serverHost, serverPort):
self.wxApp = wx.App(False)
reactor.registerWxApp(self.wxApp)
self.lobbyFrame = gui.LobbyFrame()
internet.TCPClient.__init__(self, serverHost, serverPort, LobbyProtocolFactory(self.lobbyFrame))
def stopService(self):
internet.TCPClient.stopService(self)
print "Stop service!"
destroyedD = defer.Deferred()
self.lobbyFrame.CloseWithCallback(destroyedD.callback, True)
print "close called!"
def fired(result):
print "'Destroyed' deferred has fired with %s" % (result,)
destroyedD.addCallback(fired)
return destroyedD
CloseWithCallback
이 wx.Frame
에 defind입니다 : 여기에 응용 프로그램의 유일한 서비스입니다
def clientConnectionFailed(self, connector, reason):
print "Client connection failed: %s" % reason.getErrorMessage()
reactor.stop()
청취 서버없이 클라이언트를 실행하므로 연결이 실패하지만 일부 시간 (어쩌면 절반 이상이지만 alwa가 아닐 수도 있음) ys) :
2012-11-12 18:43:29-0500 [-] Started connecting <twisted.internet.tcp.Connector instance at 0x030E3800>
2012-11-12 18:43:30-0500 [Uninitialized] Client connection failed: Connection was refused by other side: 10061: No connection could be made because the target machine actively refused it..
2012-11-12 18:43:30-0500 [Uninitialized] Stopping factory <network.LobbyProtocol.LobbyProtocolFactory instance at 0x030E3698>
2012-11-12 18:43:30-0500 [-] Stop service!
2012-11-12 18:43:30-0500 [-] 'Destroyed' deferred has fired with True
2012-11-12 18:43:30-0500 [-] Traceback (most recent call last):
2012-11-12 18:43:30-0500 [-] File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 14669, in <lambda>
2012-11-12 18:43:30-0500 [-] lambda event: event.callable(*event.args, **event.kw))
2012-11-12 18:43:30-0500 [-] File "C:\Python26\lib\site-packages\twisted\internet\_threadedselect.py", line 232, in _interleave
2012-11-12 18:43:30-0500 [-] msg, args = self.toMainThread.get_nowait()
2012-11-12 18:43:30-0500 [-] File "C:\Python26\lib\Queue.py", line 190, in get_nowait
2012-11-12 18:43:30-0500 [-] return self.get(False)
2012-11-12 18:43:30-0500 [-] File "C:\Python26\lib\Queue.py", line 165, in get
2012-11-12 18:43:30-0500 [-] raise Empty
2012-11-12 18:43:30-0500 [-] Queue.Empty
2012-11-12 18:43:30-0500 [-] Server Shut Down.
2012-11-12 18:43:30-0500 [-] Server Shut Down.
이로 인해 불편을 겪습니다. 추적 기록이 실행되지 않도록하려면 어떻게해야합니까? 나는 무엇을 잘못 했는가?
wxreactor를 사용하고있는 것처럼 들리지만 (그렇게 말하지는 않았지만). wxreactor는 Twisted 커뮤니티 회원들의 관심 부족으로 인해 효과적으로 유지 관리되지 않습니다. 당신이 그것에 관심이 있다면, 당신은 그것을위한 약간의 유지 노력을 제공하는 것에서 이익을 얻을 것입니다. 예를 들어 버그 인 것처럼 보이는 바람직하지 않은 동작 (붙여 넣은 코드를 기반으로하는 것처럼 보임)을 발견하면 버그 보고서를 제출하고 문제를 해결하기위한 패치를 첨부해야합니다 (적어도 이전 버전을 수행해야합니다. 그래서 사람들은 버그가 있음을 알게 될 것이며, 실제로 버그를 수정하고 싶다면 버그가 필요할 수도 있습니다). –
@ Jean-Paul 칼데론 : 팁을 주셔서 고마워요! 유용한 것들을 기여하는 아이디어는 매력적입니다. 내가 시간이 있다면 나는 그렇게 할거야. – Claudiu