Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Gateway spawns unnecessary tasks #239

Closed
Bluenix2 opened this issue Feb 1, 2022 · 0 comments · Fixed by #487
Closed

Gateway spawns unnecessary tasks #239

Bluenix2 opened this issue Feb 1, 2022 · 0 comments · Fixed by #487
Assignees
Labels
Improvement Something that is already implemented but can be done better

Comments

@Bluenix2
Copy link
Contributor

Bluenix2 commented Feb 1, 2022

Description

Currently the gateway spawns two tasks to be able to use asyncio.wait() to receive an event:

  • A task waiting for the close event
  • The other task waiting for the WebSocket

This is unnecessary, as only the latter task needs to be re-created really.

Steps to fix

  1. Add an optional (potentially None) attribute to __slots__ and initialize it as None
  2. In the receive() (or if it was the run()) method check for this task and use it in asyncio.wait(), if it doesn't exist create it.
  3. Edit the code to stop cancelling the task when the WebSocket receive suceeds
@LordOfPolls LordOfPolls added the Improvement Something that is already implemented but can be done better label Feb 1, 2022
LordOfPolls added a commit that referenced this issue May 17, 2022
@LordOfPolls LordOfPolls linked a pull request May 17, 2022 that will close this issue
7 tasks
LordOfPolls added a commit that referenced this issue May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Improvement Something that is already implemented but can be done better
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants