New submission from Martin Richard:

Hi,

I would like to submit 3 trivial modifications which break a cycle each. It is 
not much, but those three cycles caused a lot of objects to be garbage 
collected. They can now be freed using the reference counting mechanism, and 
therefore, reduce the latency that may be involved by the work of the garbage 
collector in a long living process.

In asyncio/base_subprocess.py:
WriteSubprocessPipeProto.proc is a reference to a BaseSubprocessTransport 
object, which holds a reference to the WriteSubprocessPipeProto in 
self._protocol.

I break the cycle in the protocol at the end of connection_lost().

In asyncio/futures.py:
wrap_future() defines a lambda which uses a variable defined in the function, 
therefore creating a closure, referencing the wrap_future() function and 
creating a cycle.

In the (really trivial) patch, the lambda uses the argument "future" instead of 
the "fut" variable defined in a closure. The closure is not needed anymore.

This single cycle is very common, because caused when one uses getaddrinfo().

In asyncio/selectors.py:
_BaseSelectorImpl._map keeps a reference to the _SelectorMapping object, which 
also references the selector with _SelectorMapping._selector.

The reference to the map in the selector is cleared once the selector is closed.

----------
files: break-some-cycles.diff
keywords: patch
messages: 233770
nosy: martius
priority: normal
severity: normal
status: open
title: asyncio: break some cycles
Added file: http://bugs.python.org/file37657/break-some-cycles.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23209>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to