File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -328,8 +328,8 @@ async def event_stream(
328328 # on the next message and should shut itself down.
329329 new_socket_uuid : str = python_uuid .uuid4 ()
330330 _LOGGER .info ("Assigning connection ID %s for %s" , new_socket_uuid , es_id )
331- existing_socket_uuid : str = _MEMCACHED_CLIENT .get (es_routing_key ). decode ( "utf-8" )
332- if existing_socket_uuid and existing_socket_uuid != new_socket_uuid :
331+ existing_socket_uuid : bytes = _MEMCACHED_CLIENT .get (es_routing_key )
332+ if existing_socket_uuid and existing_socket_uuid . decode ( "utf-8" ) != new_socket_uuid :
333333 _LOGGER .warning ("Replacing existing connection ID with ours for %s" , es_id )
334334 _MEMCACHED_CLIENT .set (es_routing_key , new_socket_uuid )
335335
@@ -395,8 +395,11 @@ async def on_message_for_websocket(
395395 # (e.g. our UUID is not the value of the cached routing key im memcached).
396396 # This typically means we've been replaced by a new stream.
397397 # 2. We get a POISON message
398- stream_socket_uuid : str = _MEMCACHED_CLIENT .get (es_routing_key ).decode ("utf-8" )
399- if stream_socket_uuid != es_websocket_uuid :
398+ stream_socket_uuid : str = _MEMCACHED_CLIENT .get (es_routing_key )
399+ if (
400+ not stream_socket_uuid
401+ or stream_socket_uuid .decode ("utf-8" ) != es_websocket_uuid
402+ ):
400403 _LOGGER .info (
401404 "There is a new owner of %s (%s), and it is not us (%s) (stopping)..." ,
402405 es_id ,
You can’t perform that action at this time.
0 commit comments