diff options
author | Allan Saddi <allan@saddi.com> | 2010-10-05 12:07:37 -0700 |
---|---|---|
committer | Allan Saddi <allan@saddi.com> | 2010-10-05 12:07:37 -0700 |
commit | e92cb2d18c79edd26eda1b888689581a3813270b (patch) | |
tree | eadb7162d6263cd258c3b4eaee69ff6e98ad9289 | |
parent | 71f1b5fa10461386dc5e0e0d78b804c1e854591f (diff) | |
download | flup-e92cb2d18c79edd26eda1b888689581a3813270b.tar.gz |
Improvements to *_app._getConnection methods suggested by
Andrej A Antonov. Thanks!
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | flup/client/fcgi_app.py | 8 | ||||
-rw-r--r-- | flup/client/scgi_app.py | 8 |
3 files changed, 17 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2010-10-05 Allan Saddi <allan@saddi.com> + + * Improvements to *_app._getConnection methods suggested by + Andrej A Antonov. Thanks! + 2009-10-27 Allan Saddi <allan@saddi.com> * Exit gracefully if a thread cannot be started when adding a new diff --git a/flup/client/fcgi_app.py b/flup/client/fcgi_app.py index c1c15ec..f4dc9bb 100644 --- a/flup/client/fcgi_app.py +++ b/flup/client/fcgi_app.py @@ -31,6 +31,7 @@ import select import struct import socket import errno +import types __all__ = ['FCGIApp'] @@ -386,11 +387,14 @@ class FCGIApp(object): if self._connect is not None: # The simple case. Create a socket and connect to the # application. - if type(self._connect) is str: + if isinstance(self._connect, types.StringTypes): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(self._connect) + elif hasattr(socket, 'create_connection'): + sock = socket.create_connection(self._connect) else: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect(self._connect) + sock.connect(self._connect) return sock # To be done when I have more time... diff --git a/flup/client/scgi_app.py b/flup/client/scgi_app.py index c26cd58..b2f01f1 100644 --- a/flup/client/scgi_app.py +++ b/flup/client/scgi_app.py @@ -31,6 +31,7 @@ import select import struct import socket import errno +import types __all__ = ['SCGIApp'] @@ -136,11 +137,14 @@ class SCGIApp(object): return [result] def _getConnection(self): - if type(self._connect) is str: + if isinstance(self._connect, types.StringTypes): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.connect(self._connect) + elif hasattr(socket, 'create_connection'): + sock = socket.create_connection(self._connect) else: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect(self._connect) + sock.connect(self._connect) return sock _environPrefixes = ['SERVER_', 'HTTP_', 'REQUEST_', 'REMOTE_', 'PATH_', |