summaryrefslogtreecommitdiff
path: root/jsonrpclib/SimpleJSONRPCServer.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpclib/SimpleJSONRPCServer.py')
-rw-r--r--jsonrpclib/SimpleJSONRPCServer.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/jsonrpclib/SimpleJSONRPCServer.py b/jsonrpclib/SimpleJSONRPCServer.py
index 854697b..d76da73 100644
--- a/jsonrpclib/SimpleJSONRPCServer.py
+++ b/jsonrpclib/SimpleJSONRPCServer.py
@@ -1,8 +1,10 @@
import jsonrpclib
from jsonrpclib import Fault
+from jsonrpclib.jsonrpc import USE_UNIX_SOCKETS
import SimpleXMLRPCServer
import SocketServer
import socket
+import logging
import os
import types
import traceback
@@ -192,14 +194,15 @@ class SimpleJSONRPCServer(SocketServer.TCPServer, SimpleJSONRPCDispatcher):
# check Python version and decide on how to call it
vi = sys.version_info
self.address_family = address_family
- if address_family == socket.AF_UNIX:
+ if USE_UNIX_SOCKETS and address_family == socket.AF_UNIX:
# Unix sockets can't be bound if they already exist in the
# filesystem. The convention of e.g. X11 is to unlink
# before binding again.
- try:
- os.unlink(addr)
- except OSError:
- pass
+ if os.path.exists(addr):
+ try:
+ os.unlink(addr)
+ except OSError:
+ logging.warning("Could not unlink socket %s", addr)
# if python 2.5 and lower
if vi[0] < 3 and vi[1] < 6:
SocketServer.TCPServer.__init__(self, addr, requestHandler)