classification
Title: Replace asyncore
Type: Stage: needs patch
Components: asyncio Versions: Python 3.7
process
Status: open Resolution:
Dependencies: 30514 Superseder:
Assigned To: aeros Nosy List: Mariatta, aeros, barry, dankreso, grzgrzgrz3, iritkatriel, jacksonriley, nanjekyejoannah, vstinner, yselivanov
Priority: normal Keywords:

Created on 2016-10-25 18:32 by Mariatta, last changed 2021-06-22 11:44 by iritkatriel.

Messages (16)
msg279439 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2016-10-25 18:32
Deprecation warning was added to asyncore in https://bugs.python.org/issue25002

asyncore is still used in several tests and should be replaced.
msg291907 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-19 21:40
> asyncore is still used in several tests and should be replaced.

Here is the list of Python files using asyncore:

haypo@selma$ grep -l asyncore $(find -name "*.py")
./Lib/asyncore.py
./Lib/asynchat.py
./Lib/test/test_smtpd.py
./Lib/test/test_asyncore.py
./Lib/test/test_smtplib.py
./Lib/test/test_os.py
./Lib/test/test_ssl.py
./Lib/test/test_logging.py
./Lib/test/libregrtest/save_env.py
./Lib/test/test_asynchat.py
./Lib/test/test_pyclbr.py
./Lib/test/test_support.py
./Lib/test/test_poplib.py
./Lib/test/test_ftplib.py
./Lib/smtpd.py

smtpd has been rewritten with asyncio:
http://aiosmtpd.readthedocs.io/

The documentation of the smtpd module already points to aiosmtpd.

libregrtest/save_env.py only checks that asyncore.socket_map is not modified, we can keep it until asyncore is really removed.

test_support.py only tests that it's possible to have a "clean" import of asyncore, it can be easily be replaced later.

The list can reduced to:

./Lib/test/test_smtplib.py
./Lib/test/test_os.py
./Lib/test/test_ssl.py
./Lib/test/test_logging.py
./Lib/test/test_pyclbr.py
./Lib/test/test_poplib.py
./Lib/test/test_ftplib.py
msg291908 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-19 21:41
asyncore was modified to emit a DeprecationWarning:
http://bugs.python.org/issue25002#msg279417

But then a lot of code starts with to fail -Werror.

Copy of Martin Panter's msg279469:

I normally run the tests with -Werror, and the failures I get are:

* test_ssl, test_smtplib, test_poplib, test_logging, test_ftplib, test_support: tests use asyncore
* test_os: test uses asynchat (When you import asynchat, the first error complains about importing asyncore, there are actually two warnings)
* test_all: This seems to ignore DeprecationWarning; perhaps an exception for PendingDeprecationWarning should also be added?
* test_asyncore and test_asynchat: Obviously these have to still test the modules, so they should anticipate the warnings, perhaps using Serhiy’s code
* test_smtpd: smtpd module itself uses asyncore; see Issue 25008
msg294710 - (view) Author: Grzegorz Grzywacz (grzgrzgrz3) * Date: 2017-05-29 19:46
I would like to work on this issue.

I think it's a good idea to split this task into few parts/PR.

Let me start from ./Lib/test/test_poplib.py.

What about rewriting pop3 server stub using asyncio, i think requests could be handled synchronously, there will be no benefits from asynchronous.

Please let me know what you think.
msg294712 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-29 20:34
> I think it's a good idea to split this task into few parts/PR. Let me start from ./Lib/test/test_poplib.py.

Once you have a patch, open a new issue and mention it here.
msg294771 - (view) Author: Grzegorz Grzywacz (grzgrzgrz3) * Date: 2017-05-30 17:25
./Lib/test/test_poplib.py
sub-issue issue28533
msg294773 - (view) Author: Grzegorz Grzywacz (grzgrzgrz3) * Date: 2017-05-30 17:29
./Lib/test/test_poplib.py
sub-issue issue30514

Fixed issue number from previous comment
msg356355 - (view) Author: (dankreso) * Date: 2019-11-11 09:27
Hi, is this still open?

I'm happy to work on replacing asyncore usage in one of the other test files.
msg356364 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-11-11 14:38
@dankreso, the issue is still open and no one has claimed it yet. So feel free to open a pull request.
msg356369 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2019-11-11 16:54
> I'm happy to work on replacing asyncore usage in one of the other test files.

Sounds good, just let us know which one(s) you're working on. (:
msg357088 - (view) Author: Jackson Riley (jacksonriley) * Date: 2019-11-20 17:28
Lib/test/test_pyclbr.py - subissue issue38866
A trivial one!
msg379342 - (view) Author: Kyle Stanley (aeros) * (Python committer) Date: 2020-10-22 20:39
Since this issue is now a significant blocker for PEP 594 (remove stdlib dead batteries, which includes asyncore and asynchat), I'm going to prioritize working on this and assign it to myself.
msg396295 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-21 22:46
If the tests are the only thing blocking removal, does it make sense to move asyncore and asynchat to test.support and get on with removing them from the stdlib?
msg396297 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-21 23:02
Irit:
> If the tests are the only thing blocking removal, does it make sense to move asyncore and asynchat to test.support and get on with removing them from the stdlib?

Yes, it makes sense and it can be done right now, since asynchat/asyncore is deprecated since Python 3.6.
msg396319 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-22 10:45
There is actually one usage outside of the tests: Lib/smtpd.py

There is a note in the doc saying " The aiosmtpd package is a recommended replacement for this module. It is based on asyncio and provides a more straightforward API. smtpd should be considered deprecated."

https://docs.python.org/3/library/smtpd.html
msg396323 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-06-22 11:32
So the first step is to decide if it's ok to remove smtpd right now.
History
Date User Action Args
2021-06-22 11:44:05iritkatrielsetnosy: + barry
2021-06-22 11:32:50vstinnersetmessages: + msg396323
2021-06-22 10:45:07iritkatrielsetmessages: + msg396319
2021-06-21 23:02:15vstinnersetmessages: + msg396297
2021-06-21 22:46:59iritkatrielsetnosy: + iritkatriel
messages: + msg396295
2020-10-22 20:39:52aerossetassignee: aeros
messages: + msg379342
2019-11-20 17:28:56jacksonrileysetnosy: + jacksonriley
messages: + msg357088
2019-11-11 16:54:14aerossetmessages: + msg356369
2019-11-11 14:38:11nanjekyejoannahsetmessages: + msg356364
2019-11-11 09:27:48dankresosetnosy: + dankreso
messages: + msg356355
2019-10-14 23:43:37aerossetnosy: + aeros
2019-04-25 18:06:52nanjekyejoannahsetnosy: + nanjekyejoannah
2017-05-30 17:35:04gvanrossumsetnosy: - gvanrossum
2017-05-30 17:32:46Mariattasetdependencies: + test_poplib replace asyncore
2017-05-30 17:29:20grzgrzgrz3setmessages: + msg294773
2017-05-30 17:25:17grzgrzgrz3setmessages: + msg294771
2017-05-29 20:45:09Mariattasetstage: needs patch
versions: + Python 3.7
2017-05-29 20:34:16vstinnersetmessages: + msg294712
2017-05-29 19:46:56grzgrzgrz3setnosy: + grzgrzgrz3
messages: + msg294710
2017-04-19 21:41:40vstinnersetmessages: + msg291908
2017-04-19 21:40:01vstinnersetnosy: + vstinner
messages: + msg291907
2016-10-25 18:33:12Mariattasetnosy: + gvanrossum, yselivanov
components: + asyncio
2016-10-25 18:32:04Mariattacreate