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 serhiy.storchaka
Recipients Markus Mohrhard, rhettinger, serhiy.storchaka
Date 2020-04-20.16:33:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1587400391.11.0.982432007665.issue40327@roundup.psfhosted.org>
In-reply-to
Content
I afraid that this is a part of the larger issue (see also issue31165). Seems the cause is that the GIL can be released when allocate or reallocate the memory. Does your project use some memory managing hooks?

Using sys.modules.copy().items() can help a lot, because you allocate memory for new dict only once. In case of list(sys.modules.items()) you allocate memory for every key-value pair, and may allocate memory several times to resize a list.

This reduces the probability of occurring the problem in many times, but not to zero. There is still a chance that the size of the original dict increase when you allocate a memory for a new dict, so copying the data to a new dict can fail or even crash or spoil the memory.
History
Date User Action Args
2020-04-20 16:33:11serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, Markus Mohrhard
2020-04-20 16:33:11serhiy.storchakasetmessageid: <1587400391.11.0.982432007665.issue40327@roundup.psfhosted.org>
2020-04-20 16:33:11serhiy.storchakalinkissue40327 messages
2020-04-20 16:33:11serhiy.storchakacreate