Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def stop(self):
"""
Stops this transport (stops listening on the respective network port or interface).
:return:
"""
if self._state != RouterTransport.STATE_STARTED:
raise Exception('invalid state')
self._state = RouterTransport.STATE_STOPPING
d = self._port.stopListening()
def ok(_):
self._state = RouterTransport.STATE_STOPPED
self._port = None
def fail(err):
self._state = RouterTransport.STATE_FAILED
self._port = None
raise err
d.addCallbacks(ok, fail)
return d
def __init__(self, worker, transport_id, config):
RouterTransport.__init__(self, worker, transport_id, config)
def create_router_transport(worker, transport_id, config):
"""
Factory for creating router (listening) transports.
:param worker:
:param transport_id:
:param config:
:return:
"""
worker.log.info('Creating router transport for "{transport_id}" ..',
transport_id=transport_id)
if config['type'] == 'web' or (config['type'] == 'universal' and config.get('web', {})):
transport = RouterWebTransport(worker, transport_id, config)
else:
transport = RouterTransport(worker, transport_id, config)
worker.log.info('Router transport created for "{transport_id}" [transport_class={transport_class}]',
transport_id=transport_id,
transport_class=hltype(transport.__class__))
return transport
def stop(self):
"""
Stops this transport (stops listening on the respective network port or interface).
:return:
"""
if self._state != RouterTransport.STATE_STARTED:
raise Exception('invalid state')
self._state = RouterTransport.STATE_STOPPING
d = self._port.stopListening()
def ok(_):
self._state = RouterTransport.STATE_STOPPED
self._port = None
def fail(err):
self._state = RouterTransport.STATE_FAILED
self._port = None
raise err
d.addCallbacks(ok, fail)
def stop(self):
"""
Stops this transport (stops listening on the respective network port or interface).
:return:
"""
if self._state != RouterTransport.STATE_STARTED:
raise Exception('invalid state')
self._state = RouterTransport.STATE_STOPPING
d = self._port.stopListening()
def ok(_):
self._state = RouterTransport.STATE_STOPPED
self._port = None
def fail(err):
self._state = RouterTransport.STATE_FAILED
self._port = None
raise err
d.addCallbacks(ok, fail)
return d
def start(self, start_children=False, ignore=[]):
"""
Start this transport (starts listening on the respective network listening port).
:param start_children:
:return:
"""
if self._state != RouterTransport.STATE_CREATED:
raise Exception('invalid state')
# note that we are starting ..
self._state = RouterTransport.STATE_STARTING
# create transport factory
self._transport_factory, self._root_webservice = yield self._create_factory(start_children, ignore)
# create transport endpoint / listening port from transport factory
#
port = yield create_listening_port_from_config(
self._config['endpoint'],
self._cbdir,
self._transport_factory,
self._worker._reactor,
self.log,
)
# when listening:
self._port = port
def ok(_):
self._state = RouterTransport.STATE_STOPPED
self._port = None
def fail(err):
self._state = RouterTransport.STATE_FAILED
self._port = None
raise err
def __init__(self, worker, transport_id, config):
RouterTransport.__init__(self, worker, transport_id, config)
def start(self, start_children=False, ignore=[]):
"""
Start this transport (starts listening on the respective network listening port).
:param start_children:
:return:
"""
if self._state != RouterTransport.STATE_CREATED:
raise Exception('invalid state')
# note that we are starting ..
self._state = RouterTransport.STATE_STARTING
# create transport factory
self._transport_factory, self._root_webservice = yield self._create_factory(start_children, ignore)
# create transport endpoint / listening port from transport factory
#
port = yield create_listening_port_from_config(
self._config['endpoint'],
self._cbdir,
self._transport_factory,
self._worker._reactor,
self.log,
)
# when listening:
self._port = port