-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple session detection, avoid multiple tabs #8442
Conversation
2bf1081
to
7e00433
Compare
7e00433
to
6086a1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just make an (events) API request, after getting the url from server_url
(like we do in start_download
). Maybe this would have been less complicated.
@egbertbouman do you mean to All in all, the issue I found is that the events endpoint streams in a response. This is not the same as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I had a go anyway:
async with aiohttp.ClientSession() as session:
response = session.get(server_url + "/api/events", headers={"X-Api-Key": config.get("api/key")})
await response.content.readline()
initial_message = (await response.content.readline()).decode()
session_count = int(json.loads(initial_message[5:]).get("sessions", 0))
Of course this is without exception handling.
🤔 interesting code. I took some time to evaluate it, but ultimately I still think the implementation of this PR has a lower chance of scary things happening. |
Fixes #8379
This PR:
/info
route to theEventsEndpoint
.find_api_server
to query the events endpoint and return basic session/events info.