[Email-SIG] memory counsumption

Mark Sapiro mark at msapiro.net
Thu Feb 18 18:26:08 CET 2010


Vitaliyi wrote:
>
>I tried to feed 1.5Mb email message to Header(), it consumed about !Gb
>of memory and them was killed:
>
>string = read('email_message').decode('utf-8')
>decode_header(Header(string))
>
[...]
>
>Could you please tell where to look to find a solution for this issue ?


Start with the documentation. The Header() constructor accepts a single
header value, not an entire email message. the decode_header function
also accepts a single header value, not a Header instance.

You maybe want something like

msg = email.message_from_file(open('email_message'))
subj = msg['subject']

Then you could do things like email.header.Header(subj) to create a
Header instance or decode_header(subj) to decode an RFC 2447 encoded
subject.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Email-SIG mailing list