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 6642131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:53:39+00:00 2026-05-25T23:53:39+00:00

I have a Python function that adds a task queue for each email address

  • 0

I have a Python function that adds a task queue for each email address in my mailing list (thousands each time I mail them). The problem is that, even though each mail was to be sent via execution in a task queue, I still get this dreaded error:

DeadlineExceededError: The API call mail.Send() took too long to respond and was cancelled.

Any solutions?

  • 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-25T23:53:40+00:00Added an answer on May 25, 2026 at 11:53 pm

    The deadline happens during communication between your GAE instance and the RPC server that handles the mail.Send call. This, in turn, might indicate internal problems of GAE or (more likely) failure to communicate with SMTP server in timely manner.

    The latter is conceptually very similar to deadline on URLFetch call. It is possible, however, to set a custom deadline for URLFetch which largely alleviates that problem.

    Unfortunately, there is no documented analogy for Mail API. There is workaround, though, that involves providing your own make_sync_call method – which allow for more lenient deadline – as parameter of EmailMessage.send(). To produce such a method, you need to delve into the internals of Python’s interface used to make GAE RPC calls. The solution I find working looks as follows:

    from google.appengine.api import apiproxy_stub_map
    from google.appengine.api.apiproxy_stub_map import APIProxyStubMap
    
    class TimeoutAPIStub( object ):
        def __init__( self, service, deadline = 25 ):
            self.service = service
            self.deadline = deadline
    
        def CreateRPC( self ):
            rpc = apiproxy_stub_map.CreateRPC( self.service )
            rpc.deadline = self.deadline
            return rpc
    
    def create_MakeSyncCall( service, deadline = 25 ):
        apsm = APIProxyStubMap()
        apsm.RegisterStub( service, TimeoutAPIStub( service, deadline ) )
        return apsm.MakeSyncCall
    

    You can then use it to supply your custom deadline which will be honored by the resulting make_sync_call method:

    msg = EmailMessage()
    # ... prepare your email ...
    msg.send(make_sync_call = create_MakeSyncCall('mail', deadline = 300))
    

    If you want to know more about what happens under the curtains of GAE RPC calls, I suggest reading Nick Johnson’s blog post about it. This is good starting point if you’d ever want to go through the Python’s GAE RPC bindings in order to solve similar issues.

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

Sidebar

Related Questions

I have a Python list variable that contains strings. Is there a function that
I would like to have a python function that given the list mystrings =
I have a Python function that takes a numeric argument that must be an
I have a python function that makes a subprocess call to a shell script
I have a python function that randomize a dictionary representing a position specific scoring
Say I have a Python function that returns multiple values in a tuple: def
I have a python function that gets an array called row. Typically row contains
I have am writing a Python function that takes a timeout value as a
I have a python program with a global function that is painful to test
I have a small python VTK function that calculates the volume and surface area

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.