@chekunkov good idea but there are some types that could not be referenced by `WeakKeyDictionary` but could be used as cookie_jar value as in the example here: http://doc.scrapy.org/en/latest/topics/downloader-middleware.html#multiple-cookie-sessions-per-spider like int and None type.
Instead of using `WeakKeyDictionary`, i added a line in callback which explicitly removes the relevant entry from self.autoclose_sessions. Please see commit https://github.com/sardok/scrapy/commit/546286d506d787c2f54718506f3fe6edb43d3da1