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

  • SEARCH
  • Home
  • 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 8575991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:49:20+00:00 2026-06-11T19:49:20+00:00

I am trying to send 5 emails in parallel. The function scheduleEmails takes a

  • 0

I am trying to send 5 emails in parallel. The function scheduleEmails takes a list of list of 5 email addresses as an input. My code looks like as follows:

import multiprocessing
import smtplib

def sendMail(email):
    #sends email using smtplib
    # returns True in case of success, False in case of failure

def scheduleEmails(emailLst):
    """
    emailLst is a list of list of 5 emails
    emailLst = [[emailAddr1,emailAddr2,emailAddr3...emailAddr5],
                [emailAddr6...emailAddr10],
                [emailAddr11... emailAddr[15],...]
    """
    FREQUENCY = 5 # no. of emails to be send per second
    for i in range(len(emailLst)):
            p = multiprocessing.Pool(FREQUENCY)
            emails = emailLst[i]
            results = p.map(sendEmail,emails)

 scheduleEmails(someEmailLst)

The code works well but after some time, it hangs. Can you point out the mistake or suggest a better way to achieve this ?

  • 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-06-11T19:49:21+00:00Added an answer on June 11, 2026 at 7:49 pm

    How many subprocesses do you have spawned after ‘a while’? To be sure not to spam your system with zillions of subprocesses, explicitly close the multiprocessing pool after collecting the results. Also, I do not see any logic in you code that controls the actual frequency of sending emails. Consider you have 1000 lists of 5 emails in your emailLst. Your loop will spawn 1000 multiprocessing pools, i.e. 5000 subprocesses, as fast as it can. You need to implement some timing/scheduling code. In the simplest case this would be a time.sleep(1) in your loop.

    Also, multiproecessing is not really appropriate for this problem, because sending mails is not CPU bound. It’s even not I/O bound in your case I guess. You could consider threading for the purpose of outsourcing a blocking call to a thread instead of a subprocesses.

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

Sidebar

Related Questions

I'm trying to send email with some images attached in django. Code used is
I am trying to send email using c# following is my code. try {
I'm trying to send emails out using MIME::Lite with authentication. Here's the code snippet
I'm trying to send S/Mime signed and encrypted emails. I have this code: //
Trying to send an activation email for newly registered users, here's the code so
I am trying to configure Sitecore to send emails from a specific email address
am trying to send emails using codeigniter email library to send emails to users
I am trying to send emails individually to a list of recipients. I am
I am trying to send emails from smtps (secure smtp) using Indy and the
I am trying to send email using gmail from my mvc application. I am

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.