From d8d1ec544ca1a4e7e94905fddab1d71da5b42b8a Mon Sep 17 00:00:00 2001 From: Anand Aiyer Date: Sun, 4 Dec 2016 18:59:19 +0530 Subject: [PATCH] Bump version to 1.3.1 Implement Timeouts (Thanks @hosting90) Change Maintainer and URL in README --- README | 8 ++++---- rfoo/__init__.py | 2 +- rfoo/_rfoo.py | 19 +++++++++++-------- setup.py | 5 ++--- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README b/README index 92f64f9..0e92ed0 100644 --- a/README +++ b/README @@ -1,10 +1,10 @@ rfoo - Fast RPC client/server module. -Contact: Nir Aides -Email: nir@winpdb.org -Website: http://www.winpdb.org/ -Version: 1.3.0 +Maintainer: Anand Aiyer +Original Author: Nir Aides +Website: https://github.com/aaiyer/rfoo +Version: 1.3.1 rfoo (remote foo) is a fast Python RPC package which can do 160,000 RPC calls per second on a regular PC. It includes a fast serialization module diff --git a/rfoo/__init__.py b/rfoo/__init__.py index 4f1e2e7..5312c6c 100644 --- a/rfoo/__init__.py +++ b/rfoo/__init__.py @@ -53,7 +53,7 @@ from rfoo._rfoo import * -__version__ = '1.3.0' +__version__ = '1.3.1' diff --git a/rfoo/_rfoo.py b/rfoo/_rfoo.py index 4770a7a..255bb35 100644 --- a/rfoo/_rfoo.py +++ b/rfoo/_rfoo.py @@ -266,8 +266,9 @@ class Connection(object): class InetConnection(Connection): """Connection type for INET sockets.""" - def __init__(self): + def __init__(self, timeout=None): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.settimeout(timeout) #s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) Connection.__init__(self, s) @@ -278,11 +279,12 @@ class InetConnection(Connection): class SSLConnection(Connection): """Connection type for SSL wrapped INET sockets.""" - def __init__(self,ssl_context=None): + def __init__(self,ssl_context=None, timeout=None): import ssl if ssl_context == None: ssl_context = ssl.create_default_context() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.settimeout(timeout) ssl_conn = ssl_context.wrap_socket(s) #s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) Connection.__init__(self, ssl_conn) @@ -442,11 +444,12 @@ def run_in_thread(foo): class Server(object): """Serve calls over connection.""" - def __init__(self, handler_type, handler_context=None, conn=None, ssl_context=None): + def __init__(self, handler_type, handler_context=None, conn=None, ssl_context=None, timeout=None): self._handler_context = handler_context self._handler_type = handler_type self._conn = conn self._ssl_context = ssl_context + self._timeout = timeout self._stop = threading.Event() def stop(self): @@ -480,7 +483,7 @@ class Server(object): if len(rlist) == 0: continue conn, addr = self._conn.accept() - conn.settimeout(None) + conn.settimeout(self._timeout) if self._ssl_context != None: try: conn = self._ssl_context.wrap_socket(conn, server_side=True) @@ -558,11 +561,11 @@ class Server(object): class InetServer(Server): """Serve calls over INET sockets.""" - def __init__(self, handler_type, handler_context=None): + def __init__(self, handler_type, handler_context=None, timeout=None): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.settimeout(None) - Server.__init__(self, handler_type, handler_context, s) + Server.__init__(self, handler_type, handler_context, s, None, timeout) def start(self, host=LOOPBACK, port=DEFAULT_PORT): self._conn.bind((host, port)) @@ -573,7 +576,7 @@ class InetServer(Server): class SSLServer(Server): """Serve calls over SSL wrapped INET sockets.""" - def __init__(self, handler_type, handler_context=None, ssl_context=None,certfile=None,keyfile=None): + def __init__(self, handler_type, handler_context=None, ssl_context=None,certfile=None,keyfile=None, timeout=None): import ssl s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) @@ -581,7 +584,7 @@ class SSLServer(Server): if ssl_context == None and certfile != None and keyfile != None: context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) context.load_cert_chain(certfile=certfile, keyfile=keyfile) - Server.__init__(self, handler_type, handler_context, s, ssl_context) + Server.__init__(self, handler_type, handler_context, s, ssl_context, timeout) def start(self, host=LOOPBACK, port=DEFAULT_PORT): self._conn.bind((host, port)) diff --git a/setup.py b/setup.py index 96b245a..af29dde 100644 --- a/setup.py +++ b/setup.py @@ -74,11 +74,10 @@ ext_modules = [Extension("rfoo.marsh", ["rfoo/marsh.pyx"])] setup( name = 'rfoo', - version = '1.3.0-ssl-1', + version = '1.3.1', description = 'Fast RPC client/server module.', author = 'Nir Aides', - author_email = 'nir@winpdb.org', - url = 'http://www.winpdb.org/', + url = 'https://github.com/aaiyer/rfoo', license = 'BSD', packages = ['rfoo', 'rfoo.utils'], scripts = ['scripts/rconsole'],