Rename async to run_async, fixes #120
This commit is contained in:
pare
d5efea7238
commit
864c83fa2f
S'han modificat 1 arxius amb 12 adicions i 12 eliminacions
|
@ -1388,45 +1388,45 @@ class Mastodon:
|
|||
# Streaming
|
||||
###
|
||||
@api_version("1.1.0", "1.4.2")
|
||||
def stream_user(self, listener, async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
def stream_user(self, listener, run_async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
"""
|
||||
Streams events that are relevant to the authorized user, i.e. home
|
||||
timeline and notifications.
|
||||
"""
|
||||
return self.__stream('/api/v1/streaming/user', listener, async=async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
|
||||
@api_version("1.1.0", "1.4.2")
|
||||
def stream_public(self, listener, async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
def stream_public(self, listener, run_async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
"""
|
||||
Streams public events.
|
||||
"""
|
||||
return self.__stream('/api/v1/streaming/public', listener, async=async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
return self.__stream('/api/v1/streaming/public', listener, run_async=run_async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
|
||||
@api_version("1.1.0", "1.4.2")
|
||||
def stream_local(self, listener, async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
def stream_local(self, listener, run_async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
"""
|
||||
Streams local public events.
|
||||
"""
|
||||
return self.__stream('/api/v1/streaming/public/local', listener, async=async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
return self.__stream('/api/v1/streaming/public/local', listener, run_async=run_async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
|
||||
@api_version("1.1.0", "1.4.2")
|
||||
def stream_hashtag(self, tag, listener, async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
def stream_hashtag(self, tag, listener, run_async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
"""
|
||||
Stream for all public statuses for the hashtag 'tag' seen by the connected
|
||||
instance.
|
||||
"""
|
||||
if tag.startswith("#"):
|
||||
raise MastodonIllegalArgumentError("Tag parameter should omit leading #")
|
||||
return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener, async=async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener, run_async=run_async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
|
||||
@api_version("2.1.0", "2.1.0")
|
||||
def stream_list(self, id, listener, async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
def stream_list(self, id, listener, run_async=False, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC):
|
||||
"""
|
||||
Stream events for the current user, restricted to accounts on the given
|
||||
list.
|
||||
"""
|
||||
id = self.__unpack_id(id)
|
||||
return self.__stream("/api/v1/streaming/list?list={}".format(id), listener, async=async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
return self.__stream("/api/v1/streaming/list?list={}".format(id), listener, run_async=run_async, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
|
||||
|
||||
###
|
||||
# Internal helpers, dragons probably
|
||||
|
@ -1668,7 +1668,7 @@ class Mastodon:
|
|||
|
||||
return response
|
||||
|
||||
def __stream(self, endpoint, listener, params={}, async=False, reconnect_async=False, reconnect_async_wait_sec=5):
|
||||
def __stream(self, endpoint, listener, params={}, run_async=False, reconnect_async=False, reconnect_async_wait_sec=5):
|
||||
"""
|
||||
Internal streaming API helper.
|
||||
|
||||
|
@ -1765,7 +1765,7 @@ class Mastodon:
|
|||
self.running = False
|
||||
return 0
|
||||
|
||||
if async:
|
||||
if run_async:
|
||||
handle = __stream_handle(connection, connect_func, reconnect_async, reconnect_async_wait_sec)
|
||||
t = threading.Thread(args=(), daemon = True, target=handle._threadproc)
|
||||
t.start()
|
||||
|
|
Loading…
Referencia en una nova incidència