it looks like if there are any race conditions, they can be sorted out using uid and message sequence numbers.
in imap_tools, the MailMessage class wraps a class from a package called "email". quote from MailMessage's constructor: self.obj = email.message_from_bytes(raw_message_data)