Skip to content

Commit

Permalink
Tuned down logging of Python Side. More informative error message. refs
Browse files Browse the repository at this point in the history
  • Loading branch information
bartdag committed Dec 13, 2011
1 parent 280f814 commit 0b59066
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions py4j-python/src/py4j/java_gateway.py
Expand Up @@ -315,9 +315,15 @@ def __init__(self, address='localhost', port=25333, auto_close=True,
def start(self):
"""Starts the connection by connecting to the `address` and the `port`
"""
self.socket.connect((self.address, self.port))
self.is_connected = True
self.stream = self.socket.makefile('rb', 0)
try:
self.socket.connect((self.address, self.port))
self.is_connected = True
self.stream = self.socket.makefile('rb', 0)
except Exception:
msg = 'An error occurred while trying to connect to the Java '\
'server'
logger.exception(msg)
raise Py4JNetworkError(msg)

def close(self, throw_exception=False):
"""Closes the connection by closing the socket."""
Expand Down Expand Up @@ -369,7 +375,7 @@ def send_command(self, command):
# answer before the socket raises an error.
if answer.strip() == '':
self.close()
raise Py4JError()
raise Py4JError("Answer from Java side is empty")
return answer
except Exception:
#print_exc()
Expand Down Expand Up @@ -917,7 +923,10 @@ def run(self):
connection.socket.shutdown(socket.SHUT_RDWR)
connection.socket.close()
except Exception:
logger.exception('Error while waiting for a connection.')
if self.is_shutdown:
logger.info('Error while waiting for a connection.')
else:
logger.exception('Error while waiting for a connection.')

def shutdown(self):
"""Stops listening and accepting connection requests. All live
Expand Down Expand Up @@ -977,7 +986,8 @@ def run(self):
else:
logger.error('Unknown command {0}'.format(command))
except Exception:
logger.exception('Error while callback connection was waiting for'
# This is a normal exception...
logger.info('Error while callback connection was waiting for'
'a message')

try:
Expand All @@ -997,8 +1007,7 @@ def _call_proxy(self, obj_id, input):
return_message = 'y' +\
get_command_part(return_value, self.pool)
except Exception:
#print_exc()
logger.exception('There was an exception while executing the '\
logger.info('There was an exception while executing the '\
'Python Proxy on the Python Side.')
return return_message

Expand Down

0 comments on commit 0b59066

Please sign in to comment.