Message 194042 - Python tracker
> As for the __main__ dict, perhaps we're missing a decref somewhere.
Actually, it's not surprising. Blob's methods hold a reference to the __main__ globals, and there's still a Blob object alive in encodings.
If you replace the end of your script with the following:
for name, mod in sys.modules.items():
if name != 'encodings':
mod.__dict__["__blob__"] = Blob(name)
del name, mod, Blob
then at the end of the shutdown phase, remaining is empty.