Skip to content
Merged
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
6 changes: 3 additions & 3 deletions homeassistant/components/plex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
CONF_VERIFY_SSL,
EVENT_HOMEASSISTANT_STOP,
)
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
Expand Down Expand Up @@ -150,6 +151,7 @@ async def async_setup_entry(hass, entry):
hass.data[PLEX_DOMAIN][DISPATCHERS].setdefault(server_id, [])
hass.data[PLEX_DOMAIN][DISPATCHERS][server_id].append(unsub)

@callback
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is called by the Plex media server. This decorator doesn't do anything.

I think that the current code is correct?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The websocket is running in async context so we need to change the api below. The decorator here is not needed but can be used for clarity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the decorator more as a comment on the expected context.

def plex_websocket_callback(signal, data, error):
"""Handle callbacks from plexwebsocket library."""
if signal == SIGNAL_CONNECTION_STATE:
Expand All @@ -167,9 +169,7 @@ def plex_websocket_callback(signal, data, error):
entry.data[CONF_SERVER],
error,
)
asyncio.run_coroutine_threadsafe(
hass.config_entries.async_reload(entry.entry_id), hass.loop
)
hass.async_create_task(hass.config_entries.async_reload(entry.entry_id))

elif signal == SIGNAL_DATA:
async_dispatcher_send(hass, PLEX_UPDATE_PLATFORMS_SIGNAL.format(server_id))
Expand Down