Streaming error handler
This commit is contained in:
pare
e1bac5b69e
commit
b663394c6d
S'han modificat 3 arxius amb 9 adicions i 0 eliminacions
|
@ -4,6 +4,7 @@ Here's some general stuff to keep in mind, and some work that needs to be done
|
||||||
use requests over urllib, et cetera.
|
use requests over urllib, et cetera.
|
||||||
|
|
||||||
* Current TODOs:
|
* Current TODOs:
|
||||||
|
* Stream since_id and better resume
|
||||||
* Testing - test 2.3 stuff and verify it works, test pinning
|
* Testing - test 2.3 stuff and verify it works, test pinning
|
||||||
* 2.4 support:
|
* 2.4 support:
|
||||||
* Dict updates (bot flag, profile meta fields, ...?)
|
* Dict updates (bot flag, profile meta fields, ...?)
|
||||||
|
|
|
@ -227,6 +227,7 @@ User dicts
|
||||||
# from account_verify_credentials()
|
# from account_verify_credentials()
|
||||||
'moved_to_account': # If set, an account dict of the account this user has
|
'moved_to_account': # If set, an account dict of the account this user has
|
||||||
# set up as their moved-to address.
|
# set up as their moved-to address.
|
||||||
|
'bot': # Boolean indicating whether this account is automated.
|
||||||
}
|
}
|
||||||
|
|
||||||
mastodon.account_verify_credentials()["source"]
|
mastodon.account_verify_credentials()["source"]
|
||||||
|
|
|
@ -25,6 +25,11 @@ class StreamListener(object):
|
||||||
describing the notification."""
|
describing the notification."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def on_abort(self):
|
||||||
|
"""Some error happened that requires that the connection should
|
||||||
|
be aborted (or re-established)"""
|
||||||
|
pass
|
||||||
|
|
||||||
def on_delete(self, status_id):
|
def on_delete(self, status_id):
|
||||||
"""A status has been deleted. status_id is the status' integer ID."""
|
"""A status has been deleted. status_id is the status' integer ID."""
|
||||||
pass
|
pass
|
||||||
|
@ -64,11 +69,13 @@ class StreamListener(object):
|
||||||
else:
|
else:
|
||||||
line_buffer.extend(chunk)
|
line_buffer.extend(chunk)
|
||||||
except ChunkedEncodingError as err:
|
except ChunkedEncodingError as err:
|
||||||
|
self.on_abort()
|
||||||
six.raise_from(
|
six.raise_from(
|
||||||
MastodonNetworkError("Server ceased communication."),
|
MastodonNetworkError("Server ceased communication."),
|
||||||
err
|
err
|
||||||
)
|
)
|
||||||
except MastodonReadTimeout as err:
|
except MastodonReadTimeout as err:
|
||||||
|
self.on_abort()
|
||||||
six.raise_from(
|
six.raise_from(
|
||||||
MastodonReadTimeout("Timed out while reading from server."),
|
MastodonReadTimeout("Timed out while reading from server."),
|
||||||
err
|
err
|
||||||
|
|
Loading…
Referencia en una nova incidència