Commit 7850ebec authored by Olivier Cros's avatar Olivier Cros

Move source code from neo/ to neo/lib

In order to prepare the eggification of the different neo parts, we created a
new neo/lib module, containing all of the main neo's functions. It allows to
make neo a virtual namespace, and so not containing module code anymore.




git-svn-id: https://svn.erp5.org/repos/neo/trunk@2615 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 49a524f1
#
# Copyright (C) 2006-2010 Nexedi SA
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import logging as logging_std
PREFIX = '%(asctime)s %(levelname)-9s %(name)-10s'
SUFFIX = ' [%(module)14s:%(lineno)3d] %(message)s'
def setupLog(name='NEO', filename=None, verbose=False):
global logging
if verbose:
level = logging_std.DEBUG
else:
level = logging_std.INFO
fmt = PREFIX + SUFFIX
logging = logging_std.getLogger(name.upper())
for handler in logging.handlers[:]:
logging.removeHandler(handler)
if filename is None:
handler = logging_std.StreamHandler()
else:
handler = logging_std.FileHandler(filename)
handler.setFormatter(logging_std.Formatter(fmt))
logging.setLevel(level)
logging.addHandler(handler)
logging.propagate = 0
# Create default logger
setupLog()
import pkg_resources
pkg_resources.declare_namespace(__name__)
......@@ -15,19 +15,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import neo
import neo.lib
from neo.node import NodeManager
from neo.event import EventManager
from neo.connection import ListeningConnection
from neo.exception import PrimaryFailure
from neo.lib.node import NodeManager
from neo.lib.event import EventManager
from neo.lib.connection import ListeningConnection
from neo.lib.exception import PrimaryFailure
from neo.admin.handler import AdminEventHandler, MasterEventHandler, \
MasterRequestEventHandler
from neo.connector import getConnectorHandler
from neo.bootstrap import BootstrapManager
from neo.pt import PartitionTable
from neo.protocol import NodeTypes, NodeStates, Packets, Errors
from neo.live_debug import register as registerLiveDebugger
from neo.lib.connector import getConnectorHandler
from neo.lib.bootstrap import BootstrapManager
from neo.lib.pt import PartitionTable
from neo.lib.protocol import NodeTypes, NodeStates, Packets, Errors
from neo.lib.live_debug import register as registerLiveDebugger
class Dispatcher:
"""Dispatcher use to redirect master request to handler"""
......@@ -68,7 +68,7 @@ class Application(object):
self.server = config.getBind()
self.master_addresses = config.getMasters()
neo.logging.debug('IP address is %s, port is %d', *(self.server))
neo.lib.logging.debug('IP address is %s, port is %d', *(self.server))
# The partition table is initialized after getting the number of
# partitions.
......@@ -105,7 +105,7 @@ class Application(object):
while True:
self.em.poll(1)
except PrimaryFailure:
neo.logging.error('primary master is down')
neo.lib.logging.error('primary master is down')
def connectToPrimary(self):
......
......@@ -17,11 +17,11 @@
import neo
from neo.handler import EventHandler
from neo import protocol
from neo.protocol import Packets, Errors
from neo.exception import PrimaryFailure
from neo.util import dump
from neo.lib.handler import EventHandler
from neo.lib import protocol
from neo.lib.protocol import Packets, Errors
from neo.lib.exception import PrimaryFailure
from neo.lib.util import dump
def forward_ask(klass):
def wrapper(self, conn, *args, **kw):
......@@ -42,7 +42,7 @@ class AdminEventHandler(EventHandler):
"""This class deals with events for administrating cluster."""
def askPartitionList(self, conn, min_offset, max_offset, uuid):
neo.logging.info("ask partition list from %s to %s for %s" %
neo.lib.logging.info("ask partition list from %s to %s for %s" %
(min_offset, max_offset, dump(uuid)))
app = self.app
# check we have one pt otherwise ask it to PMN
......@@ -61,7 +61,7 @@ class AdminEventHandler(EventHandler):
def askNodeList(self, conn, node_type):
neo.logging.info("ask node list for %s" %(node_type))
neo.lib.logging.info("ask node list for %s" %(node_type))
def node_filter(n):
return n.getType() is node_type
node_list = self.app.nm.getList(node_filter)
......@@ -70,7 +70,7 @@ class AdminEventHandler(EventHandler):
conn.answer(p)
def setNodeState(self, conn, uuid, state, modify_partition_table):
neo.logging.info("set node state for %s-%s" %(dump(uuid), state))
neo.lib.logging.info("set node state for %s-%s" %(dump(uuid), state))
node = self.app.nm.getByUUID(uuid)
if node is None:
raise protocol.ProtocolError('invalid uuid')
......@@ -144,7 +144,7 @@ class MasterEventHandler(EventHandler):
def answerNodeInformation(self, conn):
# XXX: This will no more exists when the initialization module will be
# implemented for factorize code (as done for bootstrap)
neo.logging.debug("answerNodeInformation")
neo.lib.logging.debug("answerNodeInformation")
def notifyPartitionChanges(self, conn, ptid, cell_list):
self.app.pt.update(ptid, cell_list, self.app.nm)
......@@ -176,12 +176,12 @@ class MasterRequestEventHandler(EventHandler):
client_conn.answer(packet)
def answerClusterState(self, conn, state):
neo.logging.info("answerClusterState for a conn")
neo.lib.logging.info("answerClusterState for a conn")
self.app.cluster_state = state
self._answerNeoCTL(conn, Packets.AnswerClusterState(state))
def answerPartitionTable(self, conn, ptid, row_list):
neo.logging.info("answerPartitionTable for a conn")
neo.lib.logging.info("answerPartitionTable for a conn")
client_conn, kw = self.app.dispatcher.pop(conn.getPeerId())
# sent client the partition table
self.app.sendPartitionTable(client_conn)
......
......@@ -19,9 +19,9 @@ from ZODB import BaseStorage, ConflictResolution, POSException
from zope.interface import implements
import ZODB.interfaces
from neo import setupLog
from neo.util import add64
from neo.protocol import ZERO_TID
from neo.lib import setupLog
from neo.lib.util import add64
from neo.lib.protocol import ZERO_TID
from neo.client.app import Application
from neo.client.exception import NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
......@@ -255,7 +255,8 @@ class Storage(BaseStorage.BaseStorage,
def pack(self, t, referencesf, gc=False):
if gc:
neo.logging.warning('Garbage Collection is not available in NEO, '
neo.lib.logging.warning(
'Garbage Collection is not available in NEO, '
'please use an external tool. Packing without GC.')
self.app.pack(t)
......
This diff is collapsed.
......@@ -15,8 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from neo.handler import EventHandler
from neo.protocol import ProtocolError
from neo.lib.handler import EventHandler
from neo.lib.protocol import ProtocolError
class BaseHandler(EventHandler):
"""Base class for client-side EventHandler implementations."""
......
......@@ -15,12 +15,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import neo
import neo.lib
from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.pt import MTPartitionTable as PartitionTable
from neo.protocol import NodeTypes, NodeStates, ProtocolError
from neo.util import dump
from neo.lib.pt import MTPartitionTable as PartitionTable
from neo.lib.protocol import NodeTypes, NodeStates, ProtocolError
from neo.lib.util import dump
from neo.client.exception import NEOStorageError
class PrimaryBootstrapHandler(AnswerBaseHandler):
......@@ -43,7 +43,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
if your_uuid is None:
raise ProtocolError('No UUID supplied')
app.uuid = your_uuid
neo.logging.info('Got an UUID: %s', dump(app.uuid))
neo.lib.logging.info('Got an UUID: %s', dump(app.uuid))
node = app.nm.getByAddress(conn.getAddress())
conn.setUUID(uuid)
......@@ -66,7 +66,7 @@ class PrimaryBootstrapHandler(AnswerBaseHandler):
if primary_node is None:
# I don't know such a node. Probably this information
# is old. So ignore it.
neo.logging.warning('Unknown primary master UUID: %s. ' \
neo.lib.logging.warning('Unknown primary master UUID: %s. ' \
'Ignoring.' % dump(primary_uuid))
else:
app.primary_master_node = primary_node
......@@ -94,7 +94,7 @@ class PrimaryNotificationsHandler(BaseHandler):
def connectionClosed(self, conn):
app = self.app
neo.logging.critical("connection to primary master node closed")
neo.lib.logging.critical("connection to primary master node closed")
conn.close()
app.master_conn = None
app.primary_master_node = None
......@@ -104,19 +104,19 @@ class PrimaryNotificationsHandler(BaseHandler):
app = self.app
if app.master_conn is not None:
assert conn is app.master_conn
neo.logging.critical("connection timeout to primary master node " \
"expired")
neo.lib.logging.critical(
"connection timeout to primary master node expired")
BaseHandler.timeoutExpired(self, conn)
def peerBroken(self, conn):
app = self.app
if app.master_conn is not None:
assert conn is app.master_conn
neo.logging.critical("primary master node is broken")
neo.lib.logging.critical("primary master node is broken")
BaseHandler.peerBroken(self, conn)
def stopOperation(self, conn):
neo.logging.critical("master node ask to stop operation")
neo.lib.logging.critical("master node ask to stop operation")
def invalidateObjects(self, conn, tid, oid_list):
app = self.app
......
......@@ -18,10 +18,10 @@
from ZODB.TimeStamp import TimeStamp
from ZODB.POSException import ConflictError
import neo
import neo.lib
from neo.client.handlers import BaseHandler, AnswerBaseHandler
from neo.protocol import NodeTypes, ProtocolError, LockState
from neo.util import dump
from neo.lib.protocol import NodeTypes, ProtocolError, LockState
from neo.lib.util import dump
from neo.client.exception import NEOStorageError, NEOStorageNotFoundError
from neo.client.exception import NEOStorageDoesNotExistError
......@@ -74,7 +74,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
local_var = self.app.local_var
object_stored_counter_dict = local_var.object_stored_counter_dict[oid]
if conflicting:
neo.logging.info('%r report a conflict for %r with %r', conn,
neo.lib.logging.info('%r report a conflict for %r with %r', conn,
dump(oid), dump(serial))
conflict_serial_dict = local_var.conflict_serial_dict
if serial in object_stored_counter_dict:
......@@ -96,7 +96,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
raise NEOStorageError('Wrong TID, transaction not started')
def answerTIDsFrom(self, conn, tid_list):
neo.logging.debug('Get %d TIDs from %r', len(tid_list), conn)
neo.lib.logging.debug('Get %d TIDs from %r', len(tid_list), conn)
assert not self.app.local_var.tids_from.intersection(set(tid_list))
self.app.local_var.tids_from.update(tid_list)
......@@ -144,7 +144,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
raise ConflictError, 'Lock wait timeout for oid %s on %r' % (
dump(oid), conn)
elif status == LockState.GRANTED:
neo.logging.info('Store of oid %s was successful, but after ' \
neo.lib.logging.info('Store of oid %s was successful, but after ' \
'timeout.', dump(oid))
# XXX: Not sure what to do in this case yet, for now do nothing.
else:
......
......@@ -18,7 +18,7 @@
from ZODB import BaseStorage
from zope.interface import implements
import ZODB.interfaces
from neo.util import u64, add64
from neo.lib.util import u64, add64
from neo.client.exception import NEOStorageCreationUndoneError
from neo.client.exception import NEOStorageNotFoundError
......
......@@ -16,8 +16,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from threading import Thread, Event, enumerate as thread_enum
from neo.locking import Lock
import neo
from neo.lib.locking import Lock
import neo.lib
class _ThreadedPoll(Thread):
"""Polling thread."""
......@@ -34,7 +34,7 @@ class _ThreadedPoll(Thread):
self._stop = Event()
def run(self):
neo.logging.debug('Started %s', self)
neo.lib.logging.debug('Started %s', self)
while not self.stopping():
# First check if we receive any new message from other node
try:
......@@ -42,8 +42,8 @@ class _ThreadedPoll(Thread):
# interrupt this call when stopping.
self.em.poll(1)
except:
self.neo.logging.error('poll raised, retrying', exc_info=1)
self.neo.logging.debug('Threaded poll stopped')
self.neo.lib.logging.error('poll raised, retrying', exc_info=1)
self.neo.lib.logging.debug('Threaded poll stopped')
self._stop.clear()
def stop(self):
......@@ -110,7 +110,7 @@ def psThreadedPoll(log=None):
Logs alive ThreadedPoll threads.
"""
if log is None:
log = neo.logging.debug
log = neo.lib.logging.debug
for thread in thread_enum():
if not isinstance(thread, ThreadedPoll):
continue
......
......@@ -18,12 +18,12 @@
import time
from random import shuffle
import neo
from neo.locking import RLock
from neo.protocol import NodeTypes, Packets
from neo.connection import MTClientConnection, ConnectionClosed
import neo.lib
from neo.lib.locking import RLock
from neo.lib.protocol import NodeTypes, Packets
from neo.lib.connection import MTClientConnection, ConnectionClosed
from neo.client.exception import NEOStorageError
from neo.profiling import profiler_decorator
from neo.lib.profiling import profiler_decorator
# How long before we might retry a connection to a node to which connection
# failed in the past.
......@@ -61,7 +61,7 @@ class ConnectionPool(object):
assert addr is not None
app = self.app
app.setNodeReady()
neo.logging.debug('trying to connect to %s - %s', node,
neo.lib.logging.debug('trying to connect to %s - %s', node,
node.getState())
conn = MTClientConnection(app.em, app.storage_event_handler, addr,
connector=app.connector_handler(), dispatcher=app.dispatcher)
......@@ -70,7 +70,7 @@ class ConnectionPool(object):
try:
if conn.getConnector() is None:
# This happens, if a connection could not be established.
neo.logging.error('Connection to %r failed', node)
neo.lib.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
......@@ -84,15 +84,15 @@ class ConnectionPool(object):
app._waitMessage(conn, msg_id,
handler=app.storage_bootstrap_handler)
except ConnectionClosed:
neo.logging.error('Connection to %r failed', node)
neo.lib.logging.error('Connection to %r failed', node)
self.notifyFailure(node)
return None
if app.isNodeReady():
neo.logging.info('Connected %r', node)
neo.lib.logging.info('Connected %r', node)
return conn
else:
neo.logging.info('%r not ready', node)
neo.lib.logging.info('%r not ready', node)
self.notifyFailure(node)
return NOT_READY
......@@ -107,7 +107,7 @@ class ConnectionPool(object):
not self.app.dispatcher.registered(conn):
del self.connection_dict[conn.getUUID()]
conn.close()
neo.logging.debug('_dropConnections : connection to ' \
neo.lib.logging.debug('_dropConnections : connection to ' \
'storage node %s:%d closed', *(conn.getAddress()))
if len(self.connection_dict) <= self.max_pool_size:
break
......
#
# Copyright (C) 2006-2010 Nexedi SA
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import logging as logging_std
PREFIX = '%(asctime)s %(levelname)-9s %(name)-10s'
SUFFIX = ' [%(module)14s:%(lineno)3d] %(message)s'
def setupLog(name='NEO', filename=None, verbose=False):
global logging
if verbose:
level = logging_std.DEBUG
else:
level = logging_std.INFO
fmt = PREFIX + SUFFIX
logging = logging_std.getLogger(name.upper())
for handler in logging.handlers[:]:
logging.removeHandler(handler)
if filename is None:
handler = logging_std.StreamHandler()
else:
handler = logging_std.FileHandler(filename)
handler.setFormatter(logging_std.Formatter(fmt))
logging.setLevel(level)
logging.addHandler(handler)
logging.propagate = 0
# Create default logger
setupLog()
......@@ -17,7 +17,7 @@
ATTRIBUTE_TRACKER_ENABLED = False
from neo.locking import LockUser
from neo.lib.locking import LockUser
"""
Usage example:
......
......@@ -18,10 +18,10 @@
import neo
from time import sleep
from neo.handler import EventHandler
from neo.protocol import Packets
from neo.util import dump
from neo.connection import ClientConnection
from neo.lib.handler import EventHandler
from neo.lib.protocol import Packets
from neo.lib.util import dump
from neo.lib.connection import ClientConnection
NO_SERVER = ('0.0.0.0', 0)
......@@ -106,7 +106,7 @@ class BootstrapManager(EventHandler):
conn.close()
return
neo.logging.info('connected to a primary master node')
neo.lib.logging.info('connected to a primary master node')
conn.ask(Packets.RequestIdentification(self.node_type,
self.uuid, self.server, self.name))
......@@ -120,7 +120,7 @@ class BootstrapManager(EventHandler):
if self.uuid != your_uuid:
# got an uuid from the primary master
self.uuid = your_uuid
neo.logging.info('Got a new UUID : %s' % dump(self.uuid))
neo.lib.logging.info('Got a new UUID : %s' % dump(self.uuid))
conn.setUUID(uuid)
def getPrimaryConnection(self, connector_handler):
......@@ -128,7 +128,7 @@ class BootstrapManager(EventHandler):
Primary lookup/connection process.
Returns when the connection is made.
"""
neo.logging.info('connecting to a primary master node')
neo.lib.logging.info('connecting to a primary master node')
em, nm = self.app.em, self.app.nm
index = 0
self.current = nm.getMasterList()[0]
......
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from ConfigParser import SafeConfigParser
from neo import util
from neo.lib import util
class ConfigurationManager(object):
......
......@@ -17,19 +17,19 @@
from time import time
import neo
from neo.locking import RLock
import neo.lib
from neo.lib.locking import RLock
from neo.protocol import PacketMalformedError, Packets, ParserState
from neo.connector import ConnectorException, ConnectorTryAgainException, \
from neo.lib.protocol import PacketMalformedError, Packets, ParserState
from neo.lib.connector import ConnectorException, ConnectorTryAgainException, \
ConnectorInProgressException, ConnectorConnectionRefusedException, \
ConnectorConnectionClosedException
from neo.util import dump
from neo.logger import PACKET_LOGGER
from neo.lib.util import dump
from neo.lib.logger import PACKET_LOGGER
from neo import attributeTracker
from neo.util import ReadBuffer
from neo.profiling import profiler_decorator
from neo.lib import attributeTracker
from neo.lib.util import ReadBuffer
from neo.lib.profiling import profiler_decorator
PING_DELAY = 6
PING_TIMEOUT = 5
......@@ -62,7 +62,7 @@ def lockCheckWrapper(func):
def wrapper(self, *args, **kw):
if not self._lock._is_owned():
import traceback
neo.logging.warning('%s called on %s instance without being ' \
neo.lib.logging.warning('%s called on %s instance without being ' \
'locked. Stack:\n%s', func.func_code.co_name,
self.__class__.__name__, ''.join(traceback.format_stack()))
# Call anyway
......@@ -163,7 +163,7 @@ class HandlerSwitcher(object):
assert len(self._pending) == 1 or self._pending[0][0]
PACKET_LOGGER.dispatch(connection, packet, 'from')
if connection.isClosed() and packet.ignoreOnClosedConnection():
neo.logging.debug('Ignoring packet %r on closed connection %r',
neo.lib.logging.debug('Ignoring packet %r on closed connection %r',
packet, connection)
return
msg_id = packet.getId()
......@@ -177,7 +177,8 @@ class HandlerSwitcher(object):
if klass and isinstance(packet, klass) or packet.isError():
handler.packetReceived(connection, packet)
else:
neo.logging.error('Unexpected answer %r in %r', packet, connection)
neo.lib.logging.error(
'Unexpected answer %r in %r', packet, connection)
notification = Packets.Notify('Unexpected answer: %r' % packet)
try:
connection.notify(notification)
......@@ -188,7 +189,8 @@ class HandlerSwitcher(object):
# apply a pending handler if no more answers are pending
while len(self._pending) > 1 and not self._pending[0][0]:
del self._pending[0]
neo.logging.debug('Apply handler %r on %r', self._pending[0][1],
neo.lib.logging.debug(
'Apply handler %r on %r', self._pending[0][1],
connection)
if timeout == self._next_timeout:
self._updateNextTimeout()
......@@ -286,12 +288,13 @@ class BaseConnection(object):
if handlers.isPending():
msg_id = handlers.checkTimeout(self, t)
if msg_id is not None:
neo.logging.info('timeout for #0x%08x with %r', msg_id, self)
neo.lib.logging.info(
'timeout for #0x%08x with %r', msg_id, self)
self.close()
self.getHandler().timeoutExpired(self)
elif self._timeout.hardExpired(t):
# critical time reach or pong not received, abort
neo.logging.info('timeout with %r', self)
neo.lib.logging.info('timeout with %r', self)
self.notify(Packets.Notify('Timeout'))
self.abort()
self.getHandler().timeoutExpired(self)
......@@ -345,9 +348,9 @@ class BaseConnection(object):
def setHandler(self, handler):
if self._handlers.setHandler(handler):
neo.logging.debug('Set handler %r on %r', handler, self)
neo.lib.logging.debug('Set handler %r on %r', handler, self)
else:
neo.logging.debug('Delay handler %r on %r', handler, self)
neo.lib.logging.debug('Delay handler %r on %r', handler, self)
def getEventManager(self):
return self.em
......@@ -386,7 +389,7 @@ class ListeningConnection(BaseConnection):
"""A listen connection."""
def __init__(self, event_manager, handler, addr, connector, **kw):
neo.logging.debug('listening to %s:%d', *addr)
neo.lib.logging.debug('listening to %s:%d', *addr)
BaseConnection.__init__(self, event_manager, handler,
addr=addr, connector=connector)
self.connector.makeListeningConnection(addr)
......@@ -395,7 +398,7 @@ class ListeningConnection(BaseConnection):
def readable(self):
try:
new_s, addr = self.connector.getNewConnection()
neo.logging.debug('accepted a connection from %s:%d', *addr)
neo.lib.logging.debug('accepted a connection from %s:%d', *addr)
handler = self.getHandler()
new_conn = ServerConnection(self.getEventManager(), handler,
connector=new_s, addr=addr)
......@@ -458,7 +461,7 @@ class Connection(BaseConnection):
return next_id
def close(self):
neo.logging.debug('closing a connector for %r', self)
neo.lib.logging.debug('closing a connector for %r', self)
BaseConnection.close(self)
if self._on_close is not None:
self._on_close()
......@@ -469,7 +472,7 @@ class Connection(BaseConnection):
def abort(self):
"""Abort dealing with this connection."""
neo.logging.debug('aborting a connector for %r', self)
neo.lib.logging.debug('aborting a connector for %r', self)
self.aborted = True
def writable(self):
......@@ -556,17 +559,19 @@ class Connection(BaseConnection):
except ConnectorConnectionClosedException:
# connection resetted by peer, according to the man, this error
# should not occurs but it seems it's false
neo.logging.debug('Connection reset by peer: %r', self.connector)
neo.lib.logging.debug(
'Connection reset by peer: %r', self.connector)
self._closure()
except:
neo.logging.debug('Unknown connection error: %r', self.connector)
neo.lib.logging.debug(
'Unknown connection error: %r', self.connector)
self._closure()
# unhandled connector exception
raise
else:
if not data:
neo.logging.debug('Connection %r closed in recv',
self.connector)
neo.lib.logging.debug(
'Connection %r closed in recv', self.connector)
self._closure()
return
self.read_buf.append(data)
......@@ -583,16 +588,18 @@ class Connection(BaseConnection):
pass
except ConnectorConnectionClosedException:
# connection resetted by peer
neo.logging.debug('Connection reset by peer: %r', self.connector)
neo.lib.logging.debug(
'Connection reset by peer: %r', self.connector)
self._closure()
except:
neo.logging.debug('Unknown connection error: %r', self.connector)
neo.lib.logging.debug(
'Unknown connection error: %r', self.connector)
# unhandled connector exception
self._closure()
raise