From 1da9ae2e3264b7e9c1258e14c9602178f45e3c6c Mon Sep 17 00:00:00 2001 From: Vivaan Verma <54081925+doublevcodes@users.noreply.github.com> Date: Sat, 1 May 2021 18:10:29 +0100 Subject: Create blocking.md --- bot/resources/tags/blocking.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 bot/resources/tags/blocking.md diff --git a/bot/resources/tags/blocking.md b/bot/resources/tags/blocking.md new file mode 100644 index 000000000..1671ff0d9 --- /dev/null +++ b/bot/resources/tags/blocking.md @@ -0,0 +1,7 @@ +**Why do we need asynchronous programming?** + +Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you did **not** use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming. + +**What is asynchronous programming?** + +An asynchronous programme utilises the `async` and `await` keywords. An asynchronous programme pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. -- cgit v1.2.3 From cc7aff5fd6fa14ecaf990d4964f333970fce516f Mon Sep 17 00:00:00 2001 From: Vivaan Verma <54081925+doublevcodes@users.noreply.github.com> Date: Sun, 16 May 2021 20:10:46 +0100 Subject: Change programme to program --- bot/resources/tags/blocking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/resources/tags/blocking.md b/bot/resources/tags/blocking.md index 1671ff0d9..5c9eeddc4 100644 --- a/bot/resources/tags/blocking.md +++ b/bot/resources/tags/blocking.md @@ -4,4 +4,4 @@ Imagine that you're coding a Discord bot and every time somebody uses a command, **What is asynchronous programming?** -An asynchronous programme utilises the `async` and `await` keywords. An asynchronous programme pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. +An asynchronous program utilises the `async` and `await` keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. -- cgit v1.2.3 From 0703de49acbb8583a914e9f755b23ef5065b5c68 Mon Sep 17 00:00:00 2001 From: Vivaan Verma <54081925+doublevcodes@users.noreply.github.com> Date: Sun, 16 May 2021 20:23:17 +0100 Subject: Finish the tag --- bot/resources/tags/blocking.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bot/resources/tags/blocking.md b/bot/resources/tags/blocking.md index 5c9eeddc4..3b9334513 100644 --- a/bot/resources/tags/blocking.md +++ b/bot/resources/tags/blocking.md @@ -4,4 +4,25 @@ Imagine that you're coding a Discord bot and every time somebody uses a command, **What is asynchronous programming?** -An asynchronous program utilises the `async` and `await` keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. +An asynchronous program utilises the `async` and `await` keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an `async` context manager or function marked with the `await` keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example: + +```py +import discord + +# Bunch of bot code + +async def ping(ctx): + await ctx.send("Pong!") +``` + +**What does the term "blocking" mean?** + +A blocking operation is wherever you do something without `await`ing it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts. + +**`async` libraries** + +The standard async library - `asyncio` +Asynchronous web requests - `aiohttp` +Talking to PostgreSQL asynchronously - `asyncpg` +MongoDB interactions asynchronously - `motor` +Check out [this](https://github.com/timofurrer/awesome-asyncio) list for even more! -- cgit v1.2.3 From 09ad22136121101c541c7200d7df4294b173859e Mon Sep 17 00:00:00 2001 From: Vivaan Verma <54081925+doublevcodes@users.noreply.github.com> Date: Sun, 16 May 2021 20:29:43 +0100 Subject: Fix tense problems Some of the first paragraph was in the past tense and some was in the present. Now everything is in the present. --- bot/resources/tags/blocking.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/resources/tags/blocking.md b/bot/resources/tags/blocking.md index 3b9334513..31d91294c 100644 --- a/bot/resources/tags/blocking.md +++ b/bot/resources/tags/blocking.md @@ -1,6 +1,6 @@ **Why do we need asynchronous programming?** -Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you did **not** use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming. +Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do **not** use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming. **What is asynchronous programming?** -- cgit v1.2.3 From e4ef23a63a7301b1aa4facefb70a971fdba90aa7 Mon Sep 17 00:00:00 2001 From: Matteo Bertucci Date: Sun, 16 May 2021 21:40:37 +0200 Subject: Constants: use in-server emojis for incident The default config is currently referencing the emoji server versions, making it unable to work with the nomination archive automation --- config-default.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config-default.yml b/config-default.yml index 30626c811..394c51c26 100644 --- a/config-default.yml +++ b/config-default.yml @@ -56,9 +56,9 @@ style: failmail: "<:failmail:633660039931887616>" - incident_actioned: "<:incident_actioned:719645530128646266>" - incident_investigating: "<:incident_investigating:719645658671480924>" - incident_unactioned: "<:incident_unactioned:719645583245180960>" + incident_actioned: "<:incident_actioned:714221559279255583>" + incident_investigating: "<:incident_investigating:714224190928191551>" + incident_unactioned: "<:incident_unactioned:714223099645526026>" status_dnd: "<:status_dnd:470326272082313216>" status_idle: "<:status_idle:470326266625785866>" -- cgit v1.2.3 From 3af548a316cc86e88a608afb565fe93d39faa8c3 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 17 May 2021 18:15:04 +0100 Subject: Fix pre-commit, since flake8 isn't a task --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 131ba9453..a9412f07d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: flake8 name: Flake8 description: This hook runs flake8 within our project's environment. - entry: poetry run task flake8 + entry: poetry run flake8 language: system types: [python] require_serial: true -- cgit v1.2.3