From ecf263dffa29ec144fb7e3dfbe9bcd8fb411c4ce Mon Sep 17 00:00:00 2001 From: Mujy Date: Tue, 6 Jul 2021 15:05:57 -0400 Subject: [PATCH] Added references to examples folder --- README.md | 9 +++++++++ docs/api.rst | 6 ++++++ examples/asynchronous.py | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/README.md b/README.md index 0e27605..f6ca6e2 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,9 @@ import aiohttp from Weverse.error import InvalidToken from Weverse.weverseasync import WeverseClientAsync +# THERE IS A MORE DETAILED EXAMPLE IN THE EXAMPLES FOLDER +# https://github.com/MujyKun/Weverse/blob/main/examples/asynchronous.py + token = "fake_token" # REQUIRED # It is advised to pass in your own web session as it is not closed in Weverse web_session = aiohttp.ClientSession() # A session is created by default @@ -61,6 +64,10 @@ import requests from Weverse.weversesync import WeverseClientSync from Weverse.error import InvalidToken + +# THERE IS A MORE DETAILED EXAMPLE IN THE EXAMPLES FOLDER +# https://github.com/MujyKun/Weverse/blob/main/examples/synchronous.py + token = "fake_token" # REQUIRED # It is advised to pass in your own web session as it is not closed in Weverse web_session = requests.Session() # A session is created by default @@ -75,5 +82,7 @@ except InvalidToken: # if only the newer posts are wanted. More info on the documentation. ``` +**[More Detailed Asynchronous Example](https://github.com/MujyKun/Weverse/blob/main/examples/asynchronous.py)** +**[More Detailed Synchronous Example](https://github.com/MujyKun/Weverse/blob/main/examples/synchronous.py)** ### **[API Documentation](https://weverse.readthedocs.io/en/latest/)** diff --git a/docs/api.rst b/docs/api.rst index 0fc5797..a086027 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -153,6 +153,9 @@ Asynchronous Usage from Weverse.error import InvalidToken from Weverse.weverseasync import WeverseClientAsync + # THERE IS A MORE DETAILED EXAMPLE IN THE EXAMPLES FOLDER + # https://github.com/MujyKun/Weverse/blob/main/examples/asynchronous.py + token = "fake_token" # REQUIRED # It is advised to pass in your own web session as it is not closed in Weverse web_session = aiohttp.ClientSession() @@ -172,6 +175,9 @@ Synchronous Usage from Weverse.weversesync import WeverseClientSync from Weverse.error import InvalidToken + # THERE IS A MORE DETAILED EXAMPLE IN THE EXAMPLES FOLDER + # https://github.com/MujyKun/Weverse/blob/main/examples/synchronous.py + token = "fake_token" # REQUIRED # It is advised to pass in your own web session as it is not closed in Weverse web_session = requests.Session() # A session is created by default diff --git a/examples/asynchronous.py b/examples/asynchronous.py index 77b8291..8ab255c 100644 --- a/examples/asynchronous.py +++ b/examples/asynchronous.py @@ -168,3 +168,10 @@ async def loop_notifications(self): if __name__ == '__main__': loop = asyncio.get_event_loop() loop.run_until_complete(Example().start()) + + # Please note that if you are running Weverse in a huge program and you are loading the entire cache, this should + # be run using asyncio.create_task + # Assuming you will not be running the Weverse section from the main part (this function) of your program, + # it would be advised to do something along the lines of the below line + # task = asyncio.create_task(Example().start()) +