mirror of https://github.com/D4-project/d4-core
chg: [server] timeout buffers
parent
1ab9deb777
commit
afa8edd08e
|
@ -13,6 +13,7 @@ from twisted.python import log
|
||||||
from twisted.python.modules import getModule
|
from twisted.python.modules import getModule
|
||||||
|
|
||||||
from twisted.internet.protocol import Protocol
|
from twisted.internet.protocol import Protocol
|
||||||
|
from twisted.protocols.policies import TimeoutMixin
|
||||||
|
|
||||||
|
|
||||||
from ctypes import *
|
from ctypes import *
|
||||||
|
@ -27,17 +28,24 @@ redis_server = redis.StrictRedis(
|
||||||
db=0,
|
db=0,
|
||||||
decode_responses=True)
|
decode_responses=True)
|
||||||
|
|
||||||
class Echo(Protocol):
|
timeout_time = 30
|
||||||
|
|
||||||
|
class Echo(Protocol, TimeoutMixin):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.buffer = b''
|
self.buffer = b''
|
||||||
|
self.setTimeout(timeout_time)
|
||||||
|
|
||||||
def dataReceived(self, data):
|
def dataReceived(self, data):
|
||||||
|
self.resetTimeout()
|
||||||
self.process_header(data)
|
self.process_header(data)
|
||||||
#print(self.transport.client)
|
#print(self.transport.client)
|
||||||
|
|
||||||
#def timeoutConnection(self):
|
def timeoutConnection(self):
|
||||||
# self.transport.abortConnection()
|
#print('timeout')
|
||||||
|
self.resetTimeout()
|
||||||
|
self.buffer = b''
|
||||||
|
#self.transport.abortConnection()
|
||||||
|
|
||||||
def unpack_header(self, data):
|
def unpack_header(self, data):
|
||||||
data_header = {}
|
data_header = {}
|
||||||
|
|
Loading…
Reference in New Issue