summaryrefslogtreecommitdiffstats
path: root/module/remote/thriftbackend/Transport.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-06-27 23:45:45 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-06-27 23:45:45 +0200
commit0c1a92dcfa6d9775d5d0da8ef5fc8d9cc40d77b9 (patch)
tree0fb4ed212d1e9e8d48c30d69644a774eb2424b23 /module/remote/thriftbackend/Transport.py
parentlittle cli improvement (diff)
downloadpyload-0c1a92dcfa6d9775d5d0da8ef5fc8d9cc40d77b9.tar.xz
thrift 0.7.0 from trunk, patched for low mem usage
Diffstat (limited to 'module/remote/thriftbackend/Transport.py')
-rw-r--r--module/remote/thriftbackend/Transport.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/module/remote/thriftbackend/Transport.py b/module/remote/thriftbackend/Transport.py
index 50638f461..5772c5a9e 100644
--- a/module/remote/thriftbackend/Transport.py
+++ b/module/remote/thriftbackend/Transport.py
@@ -1,15 +1,37 @@
# -*- coding: utf-8 -*-
from thrift.transport.TTransport import TBufferedTransport
+from thrift.transport.TZlibTransport import TZlibTransport
class Transport(TBufferedTransport):
DEFAULT_BUFFER = 4096
def __init__(self, trans, rbuf_size = DEFAULT_BUFFER):
TBufferedTransport.__init__(self, trans, rbuf_size)
+ self.handle = trans.handle
+ self.remoteaddr = trans.handle.getpeername()
+
+class TransportCompressed(TZlibTransport):
+ DEFAULT_BUFFER = 4096
+
+ def __init__(self, trans, rbuf_size = DEFAULT_BUFFER):
+ TZlibTransport.__init__(self, trans, rbuf_size)
+ self.handle = trans.handle
self.remoteaddr = trans.handle.getpeername()
class TransportFactory:
def getTransport(self, trans):
buffered = Transport(trans)
return buffered
+
+class TransportFactoryCompressed:
+ _last_trans = None
+ _last_z = None
+
+ def getTransport(self, trans, compresslevel=9):
+ if trans == self._last_trans:
+ return self._last_z
+ ztrans = TransportCompressed(Transport(trans), compresslevel)
+ self._last_trans = trans
+ self._last_z = ztrans
+ return ztrans \ No newline at end of file