Errata

Using Asyncio in Python

Errata for Using Asyncio in Python

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
1st page of Ch 2, the opening quote

Page one of Ch 2 has a broken link. It's the link to the words "Developing with Curio" at the end of the opening quote on the page. The correct link is to https://oreil.ly/IIV2e.

Corbin  Aug 05, 2020 
PDF Page Example 3-2
In the code

Using Python 3.12, I got a "DeprecationWarning: There is no current event loop"

Anonymous  Nov 30, 2023 
PDF Page 24
The last paragraph (under 3 - 'loop.run_until_complete(coro)')

Probably it should be 'not only' instead of just 'only' in this sentence:
Note that run_until_complete() will keep the loop running only until the given coro completes—but all other tasks scheduled on the loop will also run while the loop is running.

Denis  Jun 12, 2020 
Printed Page 26
2nd paragraph

2nd paragraph, sentence 2/3 reads "This package provides a ThreadPoolExecutor and a ProcessPoolExecutor. The default is thread-based, but either thread-based or pool-based executors can be used."

Should that final sentence refer to "...but either thread-based or process-based..."?

Thanks

Anonymous  Sep 20, 2020 
PDF Page 27
3rd callout

The callout 'header' says:

await loop.run_in_executor(None, func)

Remove 'await' (code does not have - and should not have - the await keyword.

Paul Weemaes  Mar 14, 2021 
PDF Page 30
I don't know

It is said there that get_running_loop() was introduced in Python 3.8, but it was in Python 3.7

Jerzy Spendel  Feb 26, 2020 
PDF Page 34-35
Example 3-7 and 3-8

The initial coro.send(None) results in RuntimeError: no running event loop

The example works closer to the text if in Example 3-7 'await asyncio.sleep(1.0)' is changed to 'await asyncio.sleep(0)'.

Joel Goodbody  Sep 02, 2020 
PDF Page 51
3rd Point

==================
The __iter__() special method must return an iterable; i.e., an object that implements the __next__() special method. In this case, it’s the same instance, because A itself also implements the __next__() special method.
==================

In place of iterable, it should be iterator. The object implementing __iter__() special method is an iterable but what __iter__() returns is an iterator object, which implements both __iter__() as well as __next__().

Aditya Bansal  Jun 21, 2021 
PDF Page 52
Example 3-25

The second-to-last line in the example is incorrect:

In print:
value = await redis.get(k)

On execution this fails with:
NameError: name 'redis' is not defined

Should be:
value = await self.redis.get(k)

Joel Goodbody  Sep 02, 2020 
Printed Page 52
Code block 3-25

value = await redis.get(key)

Should be:
value = await self.redis.get(key)

Alan P  Apr 14, 2022 
Printed Page 62
Example 3-32

In print:
pending = asyncio.all_tasks()

On execution this fails with:
RuntimeError: no running event loop

Should be:
pending = asyncio.all_tasks(loop=loop)

Igor Kim  Apr 30, 2020 
PDF Page 91
Example 4-12

The ninth line in the example results in an error.

In print:
queue = janus.Queue(loop=loop)

Execution results in this error:
TypeError: __init__() got an unexpected keyword argument 'loop'

Should be:
queue = janus.Queue()

Joel Goodbody  Sep 02, 2020 
PDF Page 97
3rd paragraph

Example B-1 should be Example B-2.

Joel Goodbody  Sep 02, 2020 
PDF Page 106
Example 4-19, top of page

Third line of code on the page is incorrect.

In print:
resp.send(json.dumps(data))

When executed results in the following error:
metric-server.py:33: RuntimeWarning: coroutine 'EventSourceResponse.send' was never awaited
resp.send(json.dumps(data))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Should be:
await resp.send(json.dumps(data))

Joel Goodbody  Sep 02, 2020 
PDF Page 108
Last paragraph

Example B-1 should be Example B-3

Joel Goodbody  Sep 02, 2020 
PDF Page 110
Middle of page

The command:

$ docker run -d --rm -p 55432:5432 postgres

results in a silent error that prevents the docker container and database from staying up and running.

Error: Database is uninitialized and superuser password is not specified.
You must specify POSTGRES_PASSWORD to a non-empty value for the
superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".

You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
connections without a password. This is *not* recommended.

See PostgreSQL documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html

Perhaps this is due to a newer version of Postgres. It might be helpful to add POSTGRES_HOST_AUTH_METHOD=trust in the command in order to ensure readers can run the Docker container.

Joel Goodbody  Sep 02, 2020 
PDF Page 121
2nd paragraph (non-code)

Example B-1 should be Example B-5

Joel Goodbody  Sep 02, 2020 
PDF Page 125
2nd-to-last paragraph

Example B-1 should be Example B-4

Joel Goodbody  Sep 02, 2020