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.

classification
Title: ResourceWarnings in test_asyncio
Type: behavior Stage: resolved
Components: asyncio, Tests Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Paul McGuire, asvetlov, gvanrossum, martin.panter, vstinner, xiang.zhang, yselivanov
Priority: normal Keywords: patch

Created on 2016-08-12 12:13 by martin.panter, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue27746.patch xiang.zhang, 2016-08-18 08:30 review
Messages (9)
msg272529 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-08-12 12:13
$ ./python -bWerror -m test -r -u all
. . .
0:12:58 [ 70/402] test_asyncio
Exception ignored in: <bound method _SSLProtocolTransport.__del__ of <asyncio.sslproto._SSLProtocolTransport object at 0x7fed4638f0c0>>
Traceback (most recent call last):
  File "/media/disk/home/proj/python/cpython/Lib/asyncio/sslproto.py", line 329, in __del__
    source=self)
ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x7fed4638f0c0>
Exception ignored in: <bound method _SSLProtocolTransport.__del__ of <asyncio.sslproto._SSLProtocolTransport object at 0x7fed46317c88>>
Traceback (most recent call last):
  File "/media/disk/home/proj/python/cpython/Lib/asyncio/sslproto.py", line 329, in __del__
    source=self)
ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x7fed46317c88>
Exception ignored in: <bound method _SSLProtocolTransport.__del__ of <asyncio.sslproto._SSLProtocolTransport object at 0x7fed46310f60>>
Traceback (most recent call last):
  File "/media/disk/home/proj/python/cpython/Lib/asyncio/sslproto.py", line 329, in __del__
    source=self)
ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x7fed46310f60>
Executing <Task finished coro=<CoroutineTests.test_async_def_wrapped.<locals>.start() done, defined at /media/disk/home/proj/python/cpython/Lib/test/test_asyncio/test_pep492.py:149> result=None created at /media/disk/home/proj/python/cpython/Lib/asyncio/base_events.py:367> took 0.351 seconds

If necessary, you should be able to run with python -Wall -X tracemalloc=33 to get a stack dump where the resources (transport objects or whatever) were allocated.
msg272990 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-08-17 21:20
I marked the issue #272989 as a duplicate of this one. Copy of the msg272986 by Terry J. Reedy:

3.6, Windows 10, debug build. The following appeared before and after pulling and rebuilding today. I am reporting as per Victor's request on pydev list.

0:00:22 [ 52/402] test_asyncio passed
F:\Python\dev\36\lib\asyncio\sslproto.py:329: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x03B57658>
  source=self)
F:\Python\dev\36\lib\asyncio\sslproto.py:329: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x03B57E70>
  source=self)
F:\Python\dev\36\lib\asyncio\sslproto.py:329: ResourceWarning: unclosed transport <asyncio.sslproto._SSLProtocolTransport object at 0x03AA9038>
  source=self)
msg273017 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-18 08:30
From my observations, this is due to transport is forgotten to close in test_connect_accepted_socket. Upload a patch to add the close function.
msg273293 - (view) Author: Paul McGuire (Paul McGuire) Date: 2016-08-21 11:27
I was about to report this same issue - I get the error message even though I explicitly call transport.close(): 

C:\Python35\lib\asyncio\selector_events.py:582: ResourceWarning: unclosed transport <_SelectorDatagramTransport closing fd=232>

It looks like the _sock attribute of the Transport subclasses must be set to None in their close() methods. (The presence of a non-None _sock is used elsewhere as an indicator of whether the transport has been closed or not.
msg273298 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-08-21 14:30
The patch I submitted is about to solve the resource leak in the test suite. Paul, your problem seems to need other triage.
msg273299 - (view) Author: Paul McGuire (Paul McGuire) Date: 2016-08-21 14:47
Ok, I will submit as a separate issue.
msg273313 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-08-21 19:39
@Paul: close() is asynchronous in Python :-)
msg273321 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-08-21 23:46
STINNER Victor added the comment:
> @Paul: close() is asynchronous in Python :-)

Sorry. Async in asyncio...
msg308815 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2017-12-20 21:06
Fixed in master already.
History
Date User Action Args
2022-04-11 14:58:34adminsetgithub: 71933
2017-12-20 21:06:23asvetlovsetstatus: open -> closed

nosy: + asvetlov
messages: + msg308815

resolution: out of date
stage: patch review -> resolved
2016-08-21 23:46:22vstinnersetmessages: + msg273321
2016-08-21 19:39:07vstinnersetmessages: + msg273313
2016-08-21 14:47:07Paul McGuiresetmessages: + msg273299
2016-08-21 14:30:29xiang.zhangsetmessages: + msg273298
2016-08-21 11:52:26martin.pantersetstage: needs patch -> patch review
2016-08-21 11:27:42Paul McGuiresetnosy: + Paul McGuire
messages: + msg273293
2016-08-18 08:30:10xiang.zhangsetfiles: + issue27746.patch

nosy: + xiang.zhang
messages: + msg273017

keywords: + patch
2016-08-17 21:20:36vstinnersetmessages: + msg272990
2016-08-17 21:19:44vstinnerlinkissue27789 superseder
2016-08-12 12:13:42martin.pantercreate