Skip to content

Commit

Permalink
Switch to log.warning instead of log.warn
Browse files Browse the repository at this point in the history
log.warn is removed in Python 3.13

Close crossbario#1098
  • Loading branch information
Jenselme committed Aug 22, 2024
1 parent 7bc85b3 commit e37d449
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 94 deletions.
2 changes: 1 addition & 1 deletion autobahn/asyncio/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def start(self, loop=None):
"""

if loop is None:
self.log.warn("Using default loop")
self.log.warning("Using default loop")
loop = asyncio.get_event_loop()

return self._start(loop=loop)
Expand Down
8 changes: 4 additions & 4 deletions autobahn/asyncio/rawsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _on_handshake_complete(self):
self._session.onOpen(self)
except Exception as e:
# Exceptions raised in onOpen are fatal ..
self.log.warn("WampRawSocketProtocol: ApplicationSession constructor / onOpen raised ({err})", err=e)
self.log.warning("WampRawSocketProtocol: ApplicationSession constructor / onOpen raised ({err})", err=e)
self.abort()
else:
self.log.info("ApplicationSession started.")
Expand All @@ -316,11 +316,11 @@ def stringReceived(self, payload):
self._session.onMessage(msg)

except ProtocolError as e:
self.log.warn("WampRawSocketProtocol: WAMP Protocol Error ({err}) - aborting connection", err=e)
self.log.warning("WampRawSocketProtocol: WAMP Protocol Error ({err}) - aborting connection", err=e)
self.abort()

except Exception as e:
self.log.warn("WampRawSocketProtocol: WAMP Internal Error ({err}) - aborting connection", err=e)
self.log.warning("WampRawSocketProtocol: WAMP Internal Error ({err}) - aborting connection", err=e)
self.abort()

def send(self, msg):
Expand Down Expand Up @@ -360,7 +360,7 @@ def _on_connection_lost(self, exc):
self._session.onClose(wasClean)
except Exception as e:
# silently ignore exceptions raised here ..
self.log.warn("WampRawSocketProtocol: ApplicationSession.onClose raised ({err})", err=e)
self.log.warning("WampRawSocketProtocol: ApplicationSession.onClose raised ({err})", err=e)
self._session = None

def close(self):
Expand Down
16 changes: 8 additions & 8 deletions autobahn/twisted/choosereactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
from twisted.internet import kqreactor
kqreactor.install()
except:
log.warn('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor: {tb}', tb=traceback.format_exc())
log.warning('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor: {tb}', tb=traceback.format_exc())
else:
log.debug('Running on *BSD or MacOSX and optimal reactor (kqueue) was installed.')
else:
log.warn('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
log.warning('Running on *BSD or MacOSX, but cannot install kqueue Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
if require_optimal_reactor:
raise ReactorAlreadyInstalledError()
else:
Expand All @@ -114,11 +114,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
from twisted.internet.iocpreactor import reactor as iocpreactor
iocpreactor.install()
except:
log.warn('Running on Windows, but cannot install IOCP Twisted reactor: {tb}', tb=traceback.format_exc())
log.warning('Running on Windows, but cannot install IOCP Twisted reactor: {tb}', tb=traceback.format_exc())
else:
log.debug('Running on Windows and optimal reactor (ICOP) was installed.')
else:
log.warn('Running on Windows, but cannot install IOCP Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
log.warning('Running on Windows, but cannot install IOCP Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
if require_optimal_reactor:
raise ReactorAlreadyInstalledError()
else:
Expand All @@ -134,11 +134,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
from twisted.internet import epollreactor
epollreactor.install()
except:
log.warn('Running on Linux, but cannot install Epoll Twisted reactor: {tb}', tb=traceback.format_exc())
log.warning('Running on Linux, but cannot install Epoll Twisted reactor: {tb}', tb=traceback.format_exc())
else:
log.debug('Running on Linux and optimal reactor (epoll) was installed.')
else:
log.warn('Running on Linux, but cannot install Epoll Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
log.warning('Running on Linux, but cannot install Epoll Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor)
if require_optimal_reactor:
raise ReactorAlreadyInstalledError()
else:
Expand All @@ -156,11 +156,11 @@ def install_optimal_reactor(require_optimal_reactor=True):
# from twisted.internet import default as defaultreactor
# defaultreactor.install()
except:
log.warn('Running on "{platform}", but cannot install Select Twisted reactor: {tb}', tb=traceback.format_exc(), platform=sys.platform)
log.warning('Running on "{platform}", but cannot install Select Twisted reactor: {tb}', tb=traceback.format_exc(), platform=sys.platform)
else:
log.debug('Running on "{platform}" and optimal reactor (Select) was installed.', platform=sys.platform)
else:
log.warn('Running on "{platform}", but cannot install Select Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor, platform=sys.platform)
log.warning('Running on "{platform}", but cannot install Select Twisted reactor, because another reactor ({klass}) is already installed.', klass=current_reactor, platform=sys.platform)
if require_optimal_reactor:
raise ReactorAlreadyInstalledError()
else:
Expand Down
4 changes: 2 additions & 2 deletions autobahn/twisted/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def start(self, reactor=None):
"done" or with a Failure if something went wrong.
"""
if reactor is None:
self.log.warn("Using default reactor")
self.log.warning("Using default reactor")
from twisted.internet import reactor

return self._start(loop=reactor)
Expand Down Expand Up @@ -370,7 +370,7 @@ def done_callback(reactor, arg):
if isinstance(arg, Failure):
log.error('Something went wrong: {log_failure}', failure=arg)
try:
log.warn('Stopping reactor ..')
log.warning('Stopping reactor ..')
reactor.stop()
except ReactorNotRunning:
pass
Expand Down
47 changes: 24 additions & 23 deletions autobahn/twisted/rawsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ def _on_handshake_complete(self):
res = self._session.onOpen(self)
except Exception as e:
# Exceptions raised in onOpen are fatal ..
self.log.warn("{klass}._on_handshake_complete(): ApplicationSession constructor / onOpen raised ({err})",
klass=self.__class__.__name__, err=e)
self.log.warning("{klass}._on_handshake_complete(): ApplicationSession constructor / onOpen raised ({err})",
klass=self.__class__.__name__, err=e)
self.abort()
else:
self.log.debug('{klass}._on_handshake_complete(): {session} started (res={res}).', klass=self.__class__.__name__,
self.log.debug('{klass}._on_handshake_complete(): {session} started (res={res}).',
klass=self.__class__.__name__,
session=self._session, res=res)

def connectionLost(self, reason):
Expand All @@ -146,8 +147,8 @@ def connectionLost(self, reason):
self._session.onClose(wasClean)
except Exception as e:
# silently ignore exceptions raised here ..
self.log.warn('{klass}.connectionLost(): ApplicationSession.onClose raised "{err}"',
klass=self.__class__.__name__, err=e)
self.log.warning('{klass}.connectionLost(): ApplicationSession.onClose raised "{err}"',
klass=self.__class__.__name__, err=e)
self._session = None

def stringReceived(self, payload):
Expand All @@ -165,34 +166,34 @@ def stringReceived(self, payload):
err=e)

except InvalidUriError as e:
self.log.warn("{klass}.stringReceived: WAMP InvalidUriError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.log.warning("{klass}.stringReceived: WAMP InvalidUriError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.abort()

except ProtocolError as e:
self.log.warn("{klass}.stringReceived: WAMP ProtocolError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.log.warning("{klass}.stringReceived: WAMP ProtocolError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.abort()

except PayloadExceededError as e:
self.log.warn("{klass}.stringReceived: WAMP PayloadExceededError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.log.warning("{klass}.stringReceived: WAMP PayloadExceededError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.abort()

except SerializationError as e:
self.log.warn("{klass}.stringReceived: WAMP SerializationError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.log.warning("{klass}.stringReceived: WAMP SerializationError - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.abort()

except Exception as e:
self.log.failure()
self.log.warn("{klass}.stringReceived: WAMP Exception - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.log.warning("{klass}.stringReceived: WAMP Exception - aborting connection!\n{err}",
klass=self.__class__.__name__,
err=e)
self.abort()

def send(self, msg):
Expand All @@ -212,7 +213,7 @@ def send(self, msg):
if 0 < self._max_len_send < payload_len:
emsg = 'tried to send RawSocket message with size {} exceeding payload limit of {} octets'.format(
payload_len, self._max_len_send)
self.log.warn(emsg)
self.log.warning(emsg)
raise PayloadExceededError(emsg)
else:
self.sendString(payload)
Expand Down Expand Up @@ -279,7 +280,7 @@ def dataReceived(self, data):
#
_magic = ord(self._handshake_bytes[0:1])
if _magic != 127:
self.log.warn(
self.log.warning(
"WampRawSocketServerProtocol: invalid magic byte (octet 1) in"
" opening handshake: was {magic}, but expected 127",
magic=_magic,
Expand All @@ -306,7 +307,7 @@ def dataReceived(self, data):
serializer=ser_id,
)
else:
self.log.warn(
self.log.warning(
"WampRawSocketServerProtocol: opening handshake - no suitable serializer found (client requested {serializer}, and we have {serializers}",
serializer=ser_id,
serializers=self.factory._serializers.keys(),
Expand Down
4 changes: 2 additions & 2 deletions autobahn/wamp/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def transport_check(_):
break

delay = transport.next_delay()
self.log.warn(
self.log.warning(
'trying transport {transport_idx} ("{transport_url}") using connect delay {transport_delay}',
transport_idx=transport.idx,
transport_url=transport.url,
Expand Down Expand Up @@ -831,7 +831,7 @@ def on_disconnect(session, was_clean):
)
if not txaio.is_called(done):
if not was_clean:
self.log.warn(
self.log.warning(
"Session disconnected uncleanly"
)
else:
Expand Down
Loading

0 comments on commit e37d449

Please sign in to comment.