Skip to content

Commit 436b96f

Browse files
committed
Updated README, docstrings.
1 parent 53e302e commit 436b96f

8 files changed

Lines changed: 125 additions & 104 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Python Asyncio Tutorials
1+
# Python Asyncio Tutorial
22

33
![Python](https://img.shields.io/badge/Python-v^3.9-blue.svg?logo=python&longCache=true&logoColor=white&colorB=5e81ac&style=flat-square&colorA=4c566a)
44
![Asyncio](https://img.shields.io/badge/Asyncio-v^3.4.3-blue.svg?longCache=true&logo=python&style=flat-square&logoColor=white&colorB=5e81ac&colorA=4c566a)
@@ -21,7 +21,7 @@ https://hackersandslackers.com/python-concurrency-asyncio/
2121

2222
### Part II
2323

24-
Make asynchronous HTTP requests and write to disk using **asyncio**, **aiohttp**, & **aiofiles**.
24+
Make asynchronous HTTP requests and write to disk using [**asyncio**](https://docs.python.org/3/library/asyncio.html), [**aiohttp**](https://docs.aiohttp.org/en/stable/), & [**aiofiles**](https://github.com/Tinche/aiofiles).
2525

2626
https://hackersandslackers.com/async-requests-with-aiohttp/
2727

asyncio_tutorial/logger.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
"""Custom logger."""
2-
from os import path
32
from sys import stdout
43

54
from loguru import logger as custom_logger
65

7-
from config import ENVIRONMENT
8-
96

107
def formatter(log: dict) -> str:
118
"""
@@ -49,14 +46,6 @@ def create_logger() -> custom_logger:
4946
"""
5047
custom_logger.remove()
5148
custom_logger.add(stdout, colorize=True, format=formatter)
52-
if ENVIRONMENT == "production":
53-
# Datadog JSON logs
54-
custom_logger.add(
55-
"/var/log/asyncio_tutorial/info.json",
56-
format=formatter,
57-
rotation="500 MB",
58-
compression="zip",
59-
)
6049
return custom_logger
6150

6251

asyncio_tutorial/part_I_asyncio_intro/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
async def asyncio_intro_tutorial():
1313
"""Demo of an asynchronous script's lifecycle."""
1414
LOGGER.info(f"Asyncio tutorial Part I: Intro to Asyncio.")
15-
tasks = []
15+
task_list = []
1616
future = register_future()
1717
for i in range(3):
1818
task = await create_task(simple_coroutine(i, delay=1))
19-
tasks.append(task)
19+
task_list.append(task)
2020
inspect_event_loop()
21-
await asyncio.gather(*tasks)
21+
await asyncio.gather(*task_list)
2222
future.set_result("Done")

asyncio_tutorial/part_I_asyncio_intro/futures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Future which executes an action when loop is completed."""
1+
"""Execute an action upon loop completion with Futures."""
22
import asyncio
33
from asyncio import Future
44

asyncio_tutorial/part_I_asyncio_intro/tasks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Create task from coroutine which displays a value after a delay."""
2+
from typing import Callable
23
import asyncio
34
from asyncio import Task
45

56

6-
async def create_task(coroutine) -> Task:
7+
async def create_task(coroutine: Callable) -> Task:
78
"""
89
Create asyncio tasks to be executed.
910
10-
:param coroutine: Coroutine to create async task from.
11+
:param Callable coroutine: Coroutine to create async task from.
1112
1213
:returns: Task
1314
"""

config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,3 @@
1717
"accept": "*/*",
1818
}
1919

20-
# Determine environment based on log folder
21-
ENVIRONMENT = "development"
22-
if path.isdir("/var/log/asyncio_tutorial"):
23-
ENVIRONMENT = "production"

poetry.lock

Lines changed: 115 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ chardet==4.0.0; python_version >= "3.6" and python_full_version < "3.0.0" or pyt
1111
colorama==0.4.4; python_version >= "3.5" and python_full_version < "3.0.0" and sys_platform == "win32" or sys_platform == "win32" and python_version >= "3.5" and python_full_version >= "3.5.0"
1212
idna==3.2; python_version >= "3.6"
1313
loguru==0.5.3; python_version >= "3.5"
14-
multidict==5.1.0; python_version >= "3.6"
14+
multidict==5.2.0; python_version >= "3.6"
1515
pycares==4.0.0
1616
pycparser==2.20; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
1717
typing-extensions==3.10.0.2; python_version >= "3.6"

0 commit comments

Comments
 (0)