Skip to content
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

chatexchage/client.py: catch HTTPError for refused actions #177

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

tripleee
Copy link
Contributor

With this additional exception handler, the queue is properly drained when something fails, instead of retrying forever

(Closes: #164)

With this additional exception handler, the queue is properly drained when something fails, instead of retrying forever

(Closes: Manishearth#164)
@Manishearth Manishearth reopened this Oct 23, 2023
@Manishearth Manishearth merged commit 60a006e into Manishearth:master Oct 23, 2023
9 of 20 checks passed
@tripleee tripleee deleted the frozen-traceback branch October 23, 2023 17:27
@makyen
Copy link
Contributor

makyen commented Oct 23, 2023

While removing the request from the queue upon an unresolvable HTTP error is probably a reasonable idea, this effectively causes all HTTP errors to be ignored without any way for the calling program to know that the error happened and/or that the requested action didn't take place. It would be quite a bit better to have some methodology to inform the calling program that the error occurred and that the specific request was dropped, rather than completed. Alternately, inform the calling program what error occurred, and the response from SE, and allow the requesting program the ability to drop the request or to retry the request.

@Manishearth
Copy link
Owner

Hmm, yeah. I don't have the time to design such a thing but would support it being added.

@tripleee
Copy link
Contributor Author

tripleee commented Oct 23, 2023

The threading model makes it hard to get back to where you were before you started a background thread to take care of the queue. I'm not saying it can't be done, but it's more complicated than just observing the failure and reporting back to the caller.

The problem in #164 was precisely that the error was lost forever, but the symptom was also that the program would hang around until you killed it. This actually produces a traceback in my limited testing, though there isn't much you can do from the place where you originally tried to post something.

Adapted from the earlier bug report, here is a simple demo program which now surfaces a traceback.

from time import sleep
from chatexchange.client import Client

client = Client('stackexchange.com', USER, PASS)
room = client.get_room(111121)
room.send_message('Testing')
sleep(15)
client.logout()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Posting to a frozen room should fail, but doesn't
3 participants