Asyncio Client improvements

Open
#146 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
networking

Research direction

Start with client_aio.py and the AioConnection.connect and AioReactor entry points named in the issue, then review the checklist and existing asynchronous tests. The work is complete only after the selected API, connection-handling, event-loop, locking, throttling, and testing improvements are agreed and implemented without leaving the listed issues unresolved.

Written by the indexing model from the issue text.

Description

help wanted

After thoroughly examining the module, I found multiple improvements could/should be done to asynchronous code. I'd like to open a discussion before actually implementing the code because some changes will break the current API.

  • (breaks API) AioSimpleIRCClient currently cannot be created and started once event loop has started and running asynchronous code, because AioConnection.connect calls loop.run_until_complete. In the situation described above, a RuntimeError: This event loop is already running exception is raised. AioConnection.connect should be a coroutine. Waiting for it's finishing should be caller's responsibility. Changing this function to a coroutine definitely breaks the current API.
  • Connection reset by peer should be handled.
  • SSL should be supported. Current async code does not support ssl. connection.Factory should be adapted to async code as well.
  • Circular reference between AioConnection and its underlying protocol should be removed.
  • Async version of bot should be added.
  • Debug usage of print should be removed. print is used 3 times in client_aio.py. I assume the developer forgot to remove them.
  • Make the use of custom event loops easier. If one wants to use AioSimpleIRCClient with a custom event loop, subclassing both AioReactor and AioSimpleIRCClient is required. It is supposed to be as simple as calling AioSimpleIRCClient(loop=loop)
  • loop should not be accepted as a positional argument. For example, AioReactor.__init__ should be declared as

def __init__(self, on_connect=__do_nothing, on_disconnect=__do_nothing, *, loop=None)

  • asyncio.Lock should be used over threading.Rlock.
  • Async throttler
  • Required version check
  • Better tests.
Dominant language
Python
Stars
422
Forks
91
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from jaraco/irc

All issues in jaraco/irc

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.