Re: memory counsumption
Mark Sapiro <[email protected]> Thu, 18 Feb 2010 09:26:08 -0800
| Newsgroups | gmane.comp.python.mime.devel |
|---|---|
| Organization | Not Very Much |
| Message-ID | <PC1952010021809260809376544e971@msapiro> |
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 <[email protected]> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan