Comments (2)
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.
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)
- [Support] When running something using this CE engine in PyCharm, "failed to get `usr` cookie from Stack Exchange OpenID" HOT 4
- "Limit concurrent jobs" to 1 in Travis settings for this repo HOT 1
- Update PyPI package to latest version HOT 6
- 500 Internal Server Error HOT 1
- 500 Error when reading messages HOT 1
- SE is removing OpenID HOT 9
- make: *** [run-example] Error 1 HOT 3
- Incorrect epydoc tags in docstrings HOT 2
- Travis CI migration to travis-ci.com from travis-ci.org HOT 2
- Migrate CI testing to GitHub Actions HOT 1
- Did the format of the TOO_FAST_RE message change? HOT 1
- Logout abandons pending queued messages
- Could we get a new version uploaded to PyPI? HOT 3
- chatexchange.browser.LoginError: failed to get `acct` cookie from Stack Exchange OpenID, check credentials provided for accuracy HOT 2
- examples/web_viewer.py is not working HOT 1
- Event using HOT 3
- TypeError: argument of type 'NoneType' is not iterable HOT 1
- DeprecationWarning on `Thread.setDaemon` HOT 1
- ValueError on method `client.get_me` without logging in. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatexchange.