[issue38430] Memory leak in ThreadPoolExecutor + run_in_executor

STINNER Victor report at bugs.python.org
Thu Oct 10 05:52:38 EDT 2019


STINNER Victor <vstinner at python.org> added the comment:

Well, that's a common issue when using asyncio: you forgot await.

async def main(_loop):
    while True:
        with futures.ThreadPoolExecutor() as pool:
            _loop.run_in_executor(pool, nop)
        sys.stdout.write(f'\r{get_mem():0.3f}MB')

It should be: "await _loop.run_in_executor(pool, nop)" ;-)

Sadly, PYTHONASYNCIODEBUG=1 env var doesn't complain on this bug.

See: https://docs.python.org/dev/library/asyncio-dev.html#debug-mode

----------
nosy: +vstinner
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38430>
_______________________________________


More information about the Python-bugs-list mailing list