mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Add some cleanup steps to prevent unclean reactor
This commit is contained in:
parent
fe969111ce
commit
40a37e501f
2 changed files with 15 additions and 3 deletions
|
|
@ -84,7 +84,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
|
|||
|
||||
from evennia.utils.utils import delay
|
||||
# timeout the handshakes in case the client doesn't reply at all
|
||||
delay(2, callback=self.handshake_done, timeout=True)
|
||||
self._handshake_delay = delay(2, callback=self.handshake_done, timeout=True)
|
||||
|
||||
# TCP/IP keepalive watches for dead links
|
||||
self.transport.setTcpKeepAlive(1)
|
||||
|
|
|
|||
|
|
@ -8,13 +8,15 @@ try:
|
|||
except ImportError:
|
||||
import unittest
|
||||
|
||||
from mock import Mock
|
||||
import string
|
||||
from evennia.server.portal import irc
|
||||
|
||||
from twisted.test import proto_helpers
|
||||
from twisted.trial.unittest import TestCase as TwistedTestCase
|
||||
|
||||
from .telnet import TelnetServerFactory
|
||||
from .telnet import TelnetServerFactory, TelnetProtocol
|
||||
from .portal import PORTAL_SESSIONS
|
||||
|
||||
|
||||
class TestIRC(TestCase):
|
||||
|
|
@ -84,9 +86,19 @@ class TestTelnet(TwistedTestCase):
|
|||
def setUp(self):
|
||||
super(TestTelnet, self).setUp()
|
||||
factory = TelnetServerFactory()
|
||||
factory.protocol = TelnetProtocol
|
||||
factory.sessionhandler = PORTAL_SESSIONS
|
||||
factory.sessionhandler.portal = Mock()
|
||||
self.proto = factory.buildProtocol(("localhost", 0))
|
||||
self.transport = proto_helpers.StringTransport()
|
||||
self.addCleanup(factory.sessionhandler.disconnect_all)
|
||||
|
||||
def test_connect(self):
|
||||
self.proto.makeConnection(self.transport)
|
||||
self.transport.client = ["localhost"]
|
||||
self.transport.setTcpKeepAlive = Mock()
|
||||
d = self.proto.makeConnection(self.transport)
|
||||
# TODO: Add rest of stuff for testing connection
|
||||
# clean up to prevent Unclean reactor
|
||||
self.proto.nop_keep_alive.stop()
|
||||
self.proto._handshake_delay.cancel()
|
||||
return d
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue