question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

keep_warm_callback not working, No module named 'handler'

See original GitHub issue

Context

I get this error message for the keep_warm_callback that gets scheduled, and it has been going on since I used venv3.8 before the repo migration, and still going on to this day

[ERROR] ModuleNotFoundError: No module named 'handler'
Traceback (most recent call last):
  File "/code/zappa/handler.py", line 657, in lambda_handler
    return LambdaHandler.lambda_handler(event, context)
  File "/code/zappa/handler.py", line 254, in lambda_handler
    return handler.handler(event, context)
  File "/code/zappa/handler.py", line 389, in handler
    app_function = self.import_module_and_get_function(whole_function)
  File "/code/zappa/handler.py", line 245, in import_module_and_get_function
    app_module = importlib.import_module(module)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked

-- | --

My zappa_settings.json

        "aws_region": "us-east-1",
        "profile_name": "default",
        "project_name": "flueth",
        "s3_bucket": "zappa-lambda-docker-django",
        "django_settings": "flueth.settings",
        "environment_variables": {
            "INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT": "true"
        },        
        "lambda_description": "Zappa + Docker + Django",
        "memory_size": 10240,
        "keep_warm": true,

Anyone know the issue? Are we supposed to use “zappa.handler.keep_warm_callback” here? Or do I need to set something else up with env paths or something?

https://github.com/zappa/Zappa/blob/master/zappa/cli.py#L1405

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
souravjamwal77commented, Mar 16, 2022

Hi @opqpop Can you please remove INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT from your code and try again. Let me know if it works. INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT is an experimental feature see here

0reactions
thommorcommented, Aug 31, 2022

@opqpop has the above fixed your issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModuleNotFoundError: No module named 'handler'
I have the following declaration on my main.py import model import handler import ...
Read more >
ModuleNotFoundError: no module named Python Error [Fixed]
When you try to import a module in a Python file, Python tries to resolve this module in several ways. Sometimes, Python throws...
Read more >
How to Fix ModuleNotFoundError and ImportError
How does module import work behind the scenes? · Locate, load and initialise (if required) the requested module · Define necessary names in...
Read more >
Unable to import module lambda function No ... - Edureka
AWS Lambda with Zappa fails on “Unable to import module 'handler': No module named builtins”. I solved the problem. I'm using pipenv ....
Read more >
logging.handlers — Logging handlers — Python 3.11.1 ...
The WatchedFileHandler class, located in the logging.handlers module, is a FileHandler ... The namer function is called quite a few times during rollover, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found