kopia lustrzana https://github.com/Yakifo/amqtt
Support transitions >= 0.5.0
transitions 0.5.0 replaced MachineError with ValueError and AttributeError for exceptions raised when transitioning the state machine. MachineError is still available in transitions 0.5.0, so we catch both MachineError and the relevant new exception to work with both old and new versions of transitions.pull/8/head
rodzic
f433098511
commit
d3a6d9d759
|
@ -216,9 +216,10 @@ class Broker:
|
|||
self._retained_messages = dict()
|
||||
self.transitions.start()
|
||||
self.logger.debug("Broker starting")
|
||||
except MachineError as me:
|
||||
self.logger.warn("[WARN-0001] Invalid method call at this moment: %s" % me)
|
||||
raise BrokerException("Broker instance can't be started: %s" % me)
|
||||
except (MachineError, ValueError) as exc:
|
||||
# Backwards compat: MachineError is raised by transitions < 0.5.0.
|
||||
self.logger.warning("[WARN-0001] Invalid method call at this moment: %s" % exc)
|
||||
raise BrokerException("Broker instance can't be started: %s" % exc)
|
||||
|
||||
yield from self.plugins_manager.fire_event(EVENT_BROKER_PRE_START)
|
||||
try:
|
||||
|
@ -302,9 +303,10 @@ class Broker:
|
|||
self._subscriptions = dict()
|
||||
self._retained_messages = dict()
|
||||
self.transitions.shutdown()
|
||||
except MachineError as me:
|
||||
self.logger.debug("Invalid method call at this moment: %s" % me)
|
||||
raise BrokerException("Broker instance can't be stopped: %s" % me)
|
||||
except (MachineError, ValueError) as exc:
|
||||
# Backwards compat: MachineError is raised by transitions < 0.5.0.
|
||||
self.logger.debug("Invalid method call at this moment: %s" % exc)
|
||||
raise BrokerException("Broker instance can't be stopped: %s" % exc)
|
||||
|
||||
# Fire broker_shutdown event to plugins
|
||||
yield from self.plugins_manager.fire_event(EVENT_BROKER_PRE_SHUTDOWN)
|
||||
|
@ -393,7 +395,8 @@ class Broker:
|
|||
try:
|
||||
client_session.transitions.connect()
|
||||
break
|
||||
except MachineError:
|
||||
except (MachineError, ValueError):
|
||||
# Backwards compat: MachineError is raised by transitions < 0.5.0.
|
||||
self.logger.warning("Client %s is reconnecting too quickly, make it wait" % client_session.client_id)
|
||||
# Wait a bit may be client is reconnecting too fast
|
||||
yield from asyncio.sleep(1, loop=self._loop)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
transitions==0.2.5
|
||||
transitions
|
||||
websockets==3.3.0
|
||||
passlib
|
||||
docopt
|
||||
pyyaml
|
||||
pyyaml
|
||||
|
|
2
setup.py
2
setup.py
|
@ -17,7 +17,7 @@ setup(
|
|||
include_package_data=True,
|
||||
platforms='all',
|
||||
install_requires=[
|
||||
'transitions==0.2.5',
|
||||
'transitions',
|
||||
'websockets',
|
||||
'passlib',
|
||||
'docopt',
|
||||
|
|
Ładowanie…
Reference in New Issue