Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7167409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:34:25+00:00 2026-05-28T14:34:25+00:00

I want to read mails from a mbox file and do some action based

  • 0

I want to read mails from a mbox file and do some action based on that. I don’t want to write/modify the mbox file but it will be modified by another process (Mostly adding new mails).

I am reading this documentation. http://docs.python.org/library/mailbox.html#mailbox.mbox

But I don’t understand the following

  1. Should I call lock() before reading the mail? (I am not writing to
    the file)
  2. Is there anyway I can get a callback when other process
    (thunderbird) modifies the file?
  3. Is the changes in the file reflected in the mbox object? I mean, after I create the mbox object, if a new mail is added to the file, will I access the message using the object? Or should I create a new object again?

PS: I am not allowed to install any plugins of thunderbird:(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:34:26+00:00Added an answer on May 28, 2026 at 2:34 pm
    1. No need to call Mailbox.lock() when you don’t modify the mbox. A quote from the documentation of Mailbox.lock() (emphasis my own):

      You should always lock the mailbox before making any modifications to
      its contents.

    2. Notification on file changes is out of the scope of the mailbox module. On Linux systems you can use pyinotify to get this functionality.

    3. This is also answered in the documentation:

      The default Mailbox iterator iterates over message representations, not keys as the
      default dictionary iterator does. Moreover, modification of a mailbox during iteration
      is safe and well-defined. Messages added to the mailbox after an iterator is created
      will not be seen by the iterator. Messages removed from the mailbox before the
      iterator yields them will be silently skipped, though using a key from an iterator
      may result in > a KeyError exception if the corresponding message is subsequently
      removed.

      In short, you need to create a new Mailbox instance, after the mbox file has changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file. I want read that file. But In that if
I want to read the contents of a URL but don't want to hang
I want to read and write from serial using events/interrupts. Currently, I have it
I want to read line n1->n2 from file foo.c into the current buffer. I
I want to read an xml file, apply a transform, then write to another
I want to read each line from a text file and store them in
i want to read the mails from gmail account.. i tried to login.. and
I want to read, write and create Spreadsheets in the Open Document Format with
I want to read UTF-8 input in Perl, no matter if it comes from
I want to write a shell script which will find the occurence of multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.