Question

Python Serverless Function Time Out

For context, this is a continuation of this question I asked a bit ago.

I am attempting to use Python serverless functions to talk with a MYSQL database I have set up in a project. I have one specific function that I am testing the connection with. When I attempt to connect to it, however, I get this error:

[2023-04-19 14:03:28] Begin get_profile_data activation 6675991df1454948b5991df14519482b 
[2023-04-19 14:03:29] stderr: /tmp/virtualenv/lib/python3.9/site-packages/mysql/connector/abstracts.py:130: SyntaxWarning: "is" with a literal. Did you mean "=="? 
[2023-04-19 14:03:29] stderr:   if group is 'connector_python': 
[2023-04-19 14:03:29] stderr: /tmp/virtualenv/lib/python3.9/site-packages/mysql/connector/optionfiles.py:98: SyntaxWarning: "is" with a literal. Did you mean "=="? 
[2023-04-19 14:03:29] stderr:   if group is 'connector_python': 
[2023-04-19 14:03:38] stderr: The function exceeded its time limits of 10000 milliseconds during initialization. Logs might be missing. 
[2023-04-19 14:03:28] Finished get_profile_data activation 6675991df1454948b5991df14519482b in 0s. Status: success 

Some things to note:

  1. The python warning has to do with the mysql.connector module-- not code that I wrote, but code I imported that I believe has been properly tested
  2. The issue is that “the function exceeded its time limits of 10000 milliseconds during initialization.” Would anyone happen to know what causes this or what it means?
  3. When I go to the URL this function is being served on, in my runtime logs it constantly reruns. Stated another way, when I go to this URL, I will get this message. After a few seconds, the same message will pop up. This pattern continues as the error keeps popping up every ~5 seconds. My guess is that it tries to rerun, but I wanted to see if anyone had any ideas why this happens.

If any additional information is needed let me know!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 20, 2023

Hi there,

The timeout could be caused by the Trusted sources for your MySQL cluster. If this is a dev MySQL cluster, have you tried opening the MySQL cluster temporarily to the world and see if the problem still persists?

If this is the case, what you could do is to deploy your function as part of an App on the App Platform, that way you could allow the app in the Trusted sources for your MySQL cluster.

On another note, is the function indeed supposed to run for more than 10 seconds? If this is the case, you could increase the timeout:

https://docs.digitalocean.com/products/functions/how-to/configure-functions/#resource-limits

Also, if your function is open-source, feel free to share a link to your GitHub repo here and I will be happy to test it out on my end.

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel