[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-28 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-26 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Because it did work in a gray area.
The finalization logic has slightly changed, some tricks that were working 
before now fails.
Sure, other undocumented tricks start working :)

The rule of thumb: please stop and close the asyncio loop before exiting the 
program. This rule allows for avoiding situations like this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-26 Thread Giacomo Caironi


Giacomo Caironi  added the comment:

Ok but then why does it work in python3.8 and not in python 3.9?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-26 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Because you have `test.start()` and immediately finish the script.

The interpreted goes to *shutdown* state and implicitly waits for `test.join()` 
because the test thread is not a daemon.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-26 Thread Giacomo Caironi


Giacomo Caironi  added the comment:

Why do you say that `getaddrinfo()` is called at the interpreter shutdown 
state? On my machine it works and the output is [(, 
, 6, '', ('216.58.208.132', 8333)), 
(, , 17, '', 
('216.58.208.132', 8333)), (, , 0, '', ('216.58.208.132', 8333)), (, 
, 6, '', ('2a00:1450:4002:805::2004', 8333, 0, 0)), 
(, , 17, '', 
('2a00:1450:4002:805::2004', 8333, 0, 0)), (, 
, 0, '', ('2a00:1450:4002:805::2004', 8333, 0, 0))], 
which is printed on the console

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-26 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Your snippet exits just after starting.
`getaddrinfo()` is called at the interpreter shutdown state.

I'm not sure that do you expect to get here.  We can put some effort and raise 
an error with another message but cannot make the example working.

I suggest just closing the issue; nothing to do here.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42466] asyncio loop.getaddrinfo raises RuntimeError

2020-11-25 Thread Giacomo Caironi


New submission from Giacomo Caironi :

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

--
components: asyncio
messages: 381850
nosy: asvetlov, kappa, yselivanov
priority: normal
severity: normal
status: open
title: asyncio loop.getaddrinfo raises RuntimeError
type: behavior
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com