exchangelib.errors.ErrorServerBusy #1225
-
I understand that the exchange server is under stress due to the data size of the api call. I believe I am pulling all of the calendar items, however I just need the latest 3 calendar items. I just want to know if there is anything I can do to avoid this error besides using fault tolerance, as that also doesn't always work. Is there a way to only grab the latest 3 calendar items in order to reduce the data size? calendar_items = account.calendar.all()[::-1][-3:]
for item in reversed(list(calendar_items)):
if isinstance(item, CalendarItem):
event_data = {
'subject': item.subject,
'start': item.start.astimezone(timezone("US/Eastern")).strftime('%m/%d/%Y %I:%M %p'),
'end': item.end.astimezone(timezone("US/Eastern")).strftime('%m/%d/%Y %I:%M %p'),
'location': item.location,
'body': item.body
}
calendar_events.append(event_data) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Can you expand on where you see fault tolerance not always working? To meaningfully get "latest 3 calendar items" you would need to sort on a field, since items are not guaranteed to be returned in any specific order by default. When you have done that, you can use slicing to limit the number of items fetched. Additionally, you can limit the fields you want to fetch. If you want to make sure only calendar items are returned, you can filter on In summary, here's what you can do: last_three = account.calendar\
.filter(item_class="IPF.Appointment")\
.only("subject", "start", "end", "location", "body")\
.order_by("-datetime_received")[:3] |
Beta Was this translation helpful? Give feedback.
-
Solved by using the following: for item in account.calendar.all().only("subject", "start", "end", "location", "body"):
calendar_items.append(item)
print(calendar_items)
if len(calendar_items) == 3:
break |
Beta Was this translation helpful? Give feedback.
Solved by using the following: