Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flower/api/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ async def get(self):
if app.transport == 'amqp' and app.options.broker_api:
http_api = app.options.broker_api

broker = Broker(app.capp.connection().as_uri(include_password=True),
with app.capp.connection() as conn:
broker_uri = conn.as_uri(include_password=True)
broker = Broker(broker_uri,
http_api=http_api, broker_options=self.capp.conf.broker_transport_options,
broker_use_ssl=self.capp.conf.broker_use_ssl)

Expand Down
6 changes: 5 additions & 1 deletion flower/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(self, options=None, capp=None, events=None,
max_workers_in_memory=self.options.max_workers,
max_tasks_in_memory=self.options.max_tasks)
self.started = False
self._transport = None

def start(self):
self.events.start()
Expand Down Expand Up @@ -93,7 +94,10 @@ def stop(self):

@property
def transport(self):
return getattr(self.capp.connection().transport, 'driver_type', None)
if self._transport is None:
with self.capp.connection() as conn:
self._transport = getattr(conn.transport, 'driver_type', None)
return self._transport

@property
def workers(self):
Expand Down
3 changes: 2 additions & 1 deletion flower/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def print_banner(app, ssl):
else:
logger.info("Visit me via unix socket file: %s", options.unix_socket)

logger.info('Broker: %s', app.connection().as_uri())
with app.connection() as conn:
logger.info('Broker: %s', conn.as_uri())
logger.info(
'Registered tasks: \n%s',
pformat(sorted(app.tasks.keys()))
Expand Down
8 changes: 6 additions & 2 deletions flower/views/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ async def get(self):
if app.transport == 'amqp' and app.options.broker_api:
http_api = app.options.broker_api

with app.capp.connection(connect_timeout=1.0) as conn:
broker_uri = conn.as_uri(include_password=True)
broker_url = conn.as_uri()

try:
broker = Broker(app.capp.connection(connect_timeout=1.0).as_uri(include_password=True),
broker = Broker(broker_uri,
http_api=http_api, broker_options=self.capp.conf.broker_transport_options,
broker_use_ssl=self.capp.conf.broker_use_ssl)
except NotImplementedError as exc:
Expand All @@ -31,5 +35,5 @@ async def get(self):
logger.error("Unable to get queues: '%s'", e)

self.render("broker.html",
broker_url=app.capp.connection().as_uri(),
broker_url=broker_url,
queues=queues)
4 changes: 3 additions & 1 deletion flower/views/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ async def get(self):
if json:
self.write(dict(data=list(workers.values())))
else:
with self.application.capp.connection() as conn:
broker_url = conn.as_uri()
self.render("workers.html",
workers=workers,
broker=self.application.capp.connection().as_uri(),
broker=broker_url,
autorefresh=1 if self.application.options.auto_refresh else 0)

@classmethod
Expand Down
Loading