Skip to content

Remove deprecated parameter 'loop' in Python 3.10 and newer #8

Open
@Matej-Chmel

Description

@Matej-Chmel

When running the echo server example from chapter 10 under Python 3.10 or newer a TypeError is raised:

TypeError: BaseEventLoop.create_server() got an unexpected keyword argument 'loop'

The solution is to simply remove the 'loop' argument from line 17.

coro = asyncio.start_server(handle_echo, '127.0.0.1', 8888, loop=loop) # original
coro = asyncio.start_server(handle_echo, '127.0.0.1', 8888) # solution

This can be done safely because the function asyncio.get_event_loop that is used internally by asyncio.start_server always returns the currently running loop from Python 3.6 onwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions