Coder Social home page Coder Social logo

Comments (2)

tripleee avatar tripleee commented on June 26, 2024

I'm getting a slightly better traceback with this simple demo.

#!/usr/bin/env python3

from os import environ as env
from time import sleep

from chatexchange.client import Client


client = Client('stackexchange.com', env['CHAT_EMAIL'], env['CHAT_PASSWORD'])
room = client.get_room(111121)
room.send_message('Testing')
q = client._request_queue
while not q.empty():
    print("waiting for queue to drain (%i items in queue)" % q.qsize())
    sleep(15)
client.logout()

Without the loop to wait for the queue to drain, it just quits with no indication of any error at the end of the script. (I have been wishing for other reasons that an explicit logout should make sure all messages are delivered before it disconnects, but I digress.)

The traceback shows that raise_for_status() is actually being called correctly, but there is no longer any obvious way at this point to relay the status back to the calling client.

waiting for queue to drain (1 items in queue)
Exception in thread message_sender:
Traceback (most recent call last):
  File "/home/tripleee/.pyenv/versions/3.8.2/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/tripleee/.pyenv/versions/3.8.2/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/chatexchange/client.py", line 183, in _worker
    self._do_action_despite_throttling(next_action)
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/chatexchange/client.py", line 221, in _do_action_despite_throttling
    response = self._br.send_message(room_id, text)
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/chatexchange/browser.py", line 299, in send_message
    return self.post_fkeyed(
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/chatexchange/browser.py", line 133, in post_fkeyed
    return self.post(url, data, headers)
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/chatexchange/browser.py", line 113, in post
    return self._request('post', url, data, headers, with_chat_root)
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/chatexchange/browser.py", line 102, in _request
    response.raise_for_status()
  File "/home/tripleee/git/sloshy/venv/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.stackexchange.com/chats/111121/messages/new

from chatexchange.

tripleee avatar tripleee commented on June 26, 2024

https://stackoverflow.com/questions/2829329/catch-a-threads-exception-in-the-caller-thread has some ideas to explore. Ultimately perhaps an async solution would be more manageable and robust, but then that would entail giving up compatibility with Python 2 and older versions of Python 3.

from chatexchange.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.