diff --git a/src/aioslsk/user/manager.py b/src/aioslsk/user/manager.py index aebac34..c658115 100644 --- a/src/aioslsk/user/manager.py +++ b/src/aioslsk/user/manager.py @@ -14,6 +14,7 @@ AdminMessageEvent, BlockListChangedEvent, ConnectionStateChangedEvent, + Event, EventBus, FriendListChangedEvent, KickedEvent, @@ -135,7 +136,11 @@ async def start(self): self._management_task.start() async def stop(self) -> list[asyncio.Task]: - return [self._management_task.cancel()] + cancel_tasks = [] + if task := self._management_task.cancel(): + cancel_tasks.append(task) + + return cancel_tasks def get_self(self) -> User: """Returns the user object for the current session""" @@ -277,7 +282,7 @@ def _unset_tracking_flag(self, user: User, flag: TrackingFlag) -> bool: return tracked_user.flags != TrackingFlag(0) async def _management_job(self, context: UserManagementContext): - events = [] + events: list[Event] = [] if context.friends != self._settings.users.friends: events.append(