Fix missing async in hashtag/list streams
This commit is contained in:
pare
2420a5d6de
commit
e5c50ea80d
S'han modificat 1 arxius amb 7 adicions i 5 eliminacions
|
@ -1387,7 +1387,7 @@ class Mastodon:
|
||||||
"""
|
"""
|
||||||
if tag.startswith("#"):
|
if tag.startswith("#"):
|
||||||
raise MastodonIllegalArgumentError("Tag parameter should omit leading #")
|
raise MastodonIllegalArgumentError("Tag parameter should omit leading #")
|
||||||
return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener)
|
return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener, async=async)
|
||||||
|
|
||||||
@api_version("2.1.0", "2.1.0")
|
@api_version("2.1.0", "2.1.0")
|
||||||
def stream_list(self, id, listener, async=False):
|
def stream_list(self, id, listener, async=False):
|
||||||
|
@ -1396,7 +1396,7 @@ class Mastodon:
|
||||||
list.
|
list.
|
||||||
"""
|
"""
|
||||||
id = self.__unpack_id(id)
|
id = self.__unpack_id(id)
|
||||||
return self.__stream("/api/v1/streaming/list?list={}".format(id), listener)
|
return self.__stream("/api/v1/streaming/list?list={}".format(id), listener, async=async)
|
||||||
|
|
||||||
###
|
###
|
||||||
# Internal helpers, dragons probably
|
# Internal helpers, dragons probably
|
||||||
|
@ -1670,9 +1670,11 @@ class Mastodon:
|
||||||
|
|
||||||
class __stream_handle():
|
class __stream_handle():
|
||||||
def __init__(self, connection):
|
def __init__(self, connection):
|
||||||
|
self.closed = False
|
||||||
self.connection = connection
|
self.connection = connection
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
self.closed = True
|
||||||
self.connection.close()
|
self.connection.close()
|
||||||
|
|
||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
|
@ -1682,10 +1684,10 @@ class Mastodon:
|
||||||
self._thread = threading.current_thread()
|
self._thread = threading.current_thread()
|
||||||
with closing(connection) as r:
|
with closing(connection) as r:
|
||||||
try:
|
try:
|
||||||
listener.handle_stream(r.iter_lines())
|
listener.handle_stream(r.iter_lines(chunk_size = 1, decode_unicode = True))
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
# Eat AttributeError from requests if user closes early
|
if not self.closed:
|
||||||
pass
|
raise e
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
handle = __stream_handle(connection)
|
handle = __stream_handle(connection)
|
||||||
|
|
Loading…
Referencia en una nova incidència