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 Costas
Recipients Costas, barry, r.david.murray
Date 2016-07-15.19:17:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1468610275.0.0.18157946386.issue27522@psf.upfronthosting.co.za>
In-reply-to
Content
Background: We have two (clusters of) servers running a high-throughput websocket application. One runs under Python 2.7, the other has been migrated to 3.4. Very similar code runs on both servers, and both manually call the gc periodically to reduce latency. 

Problem: We noticed that under load the 3.4 server seems to slowly "leak" memory between gc collections, while the 2.7 server doesn't have this issue.

Investigation: I tracked down the source of all the garbage to email.feedparser, which is used by http.server to parse the headers of incoming requests. The initialiser of the FeedParser class creates a reference cycle by putting a lambda function into a member variable. The lambda contains a closure with its surrounding scope that points to the object, and the object points back to the lambda. 

Proposed fix: The lambda can be harmlessly replaced by a boolean value, which doesn't cause the problem, and it's much more readable too. I'm attaching a little patch.
History
Date User Action Args
2016-07-15 19:17:55Costassetrecipients: + Costas, barry, r.david.murray
2016-07-15 19:17:55Costassetmessageid: <1468610275.0.0.18157946386.issue27522@psf.upfronthosting.co.za>
2016-07-15 19:17:54Costaslinkissue27522 messages
2016-07-15 19:17:54Costascreate