Comments (5)
.all()
is greedy and fetches all items in one go. Attachments load their content when accessing attachment.content
or attachment.item
, which will increase your memory usage while iterating.
If you have attributes that you don't care about, you can optimize your memory usage by fetching only the attributes you need:
for m in account.inbox.all().only('item_id', 'changekey', 'attachments'):
...
Finally, res = account.inbox.all()
creates an internal cache of the search results so a second iteration over res
does not hit the server. If you will never need this cache, you can add .iterator()
at the end of your filter, i.e:
for m in account.inbox.all().iterator():
...
from exchangelib.
Closed this with a recommendation to use this optimisation and the latest 1.7.5 release:
for m in account.inbox.all().only('item_id', 'changekey', 'attachments').iterator():
...
for attachment in item.attachments:
...
If this doesn't help, please provide measurements or other insight into the problem.
from exchangelib.
Does Python crash at 600MB usage? How much raw data is the 5000 messages in total? If your inbox contains large attachments, 600MB may not be unreasonable.
from exchangelib.
638995b clears some elements after XML parsing, which should ease the memory pressure a bit. Can you try if that helps?
A more optimal solution would be to change from a greedy XML parser to an iterating parser, but that would be quite painful.
from exchangelib.
Hi @KarelCoudijzer Did you get to the bottom of this? If you are still having problems, I think #52 would make it possible to create a generator that makes .all()
non-greedy.
from exchangelib.
Related Issues (20)
- How to get the itself mailbox and letters from subscription webhook
- Implement SubscribeToAllFolders attribute to subscription requests HOT 3
- about filter specified attachment's name HOT 3
- How to login via UPN or (non-primary) smtp_address?
- can't accces contacts from [email protected] via mailbox delegation(ServiceCredentials) HOT 2
- Reading mime contents of .msg file type attachments HOT 1
- Adding The "X-Auto-Response-Suppress" Header Ignored when sending emails HOT 4
- Creating an Account object raise SSLError with Office 365 account. HOT 1
- Account object doesn't return data of the `primary_smtp_address` mailbox HOT 1
- Getting Invalid Credentials on Live Server(Cpanel) while reading Outlook mailbox but works on local server HOT 3
- MSAL on Office 365 does not describe the way to connect for daemon processes HOT 3
- item.is_read error HOT 6
- `ErrorNonExistentMailbox` in version 5.1.0 but not in 4.8.0 HOT 4
- I want to know if exchangelib python librarie work also with microsoft exchange 2016-2019
- Unable to access in-place archive HOT 8
- Trouble accessing pidTagIconIndex canonical property on message HOT 1
- exchangelib.errors.ErrorFolderNotFound: No subfolder with name '<custom folder>' when using exchangelib 5.1.0 on Ubuntu 20.04 HOT 28
- Unable to join meetings created through CalendarItem. HOT 3
- attached mail as ItemAttachment HOT 10
- Linting error: `account.inbox.filter(...)` HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exchangelib.