This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kappa
Recipients asvetlov, kappa, yselivanov
Date 2020-11-25.16:57:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606323474.88.0.370019407414.issue42466@roundup.psfhosted.org>
In-reply-to
Content
import asyncio
import traceback
from threading import Thread


class Test(Thread):
    def __init__(self):
        super().__init__()
        self.loop = asyncio.new_event_loop()

    async def getaddrinfo(self, loop):
        try:
            print(await loop.getaddrinfo("www.google.com", 8333))
        except Exception:
            print(traceback.format_exc())

    def run(self):
        loop = self.loop
        asyncio.set_event_loop(loop)
        asyncio.run_coroutine_threadsafe(self.getaddrinfo(loop), loop)
        loop.run_forever()


test = Test()
test.start()

Executing the previous code throws RuntimeError("can't register atexit after shutdown") only in python3.9. Strangely it doesn't happen when I execute the code in interactive mode. 

I think this is related to https://bugs.python.org/issue41962
History
Date User Action Args
2020-11-25 16:57:54kappasetrecipients: + kappa, asvetlov, yselivanov
2020-11-25 16:57:54kappasetmessageid: <1606323474.88.0.370019407414.issue42466@roundup.psfhosted.org>
2020-11-25 16:57:54kappalinkissue42466 messages
2020-11-25 16:57:54kappacreate