File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ SDIST := dist/$(shell python setup.py --fullname).tar.gz
22SLEEP := 0
33TIMEOUT := 3
44
5- .PHONY : default clean test up upload
5+ .PHONY : all clean test up upload
66
7- default : $(SDIST )
7+ all : $(SDIST )
88
99clean :
1010 rm -rf dist
@@ -17,7 +17,7 @@ upload: $(SDIST)
1717up :
1818 SLEEP=$(SLEEP ) python -m lambda_gateway -t $(TIMEOUT ) lambda_function.lambda_handler
1919
20- coverage.xml : $(shell find . -name '* .py' -not -path './. * ')
20+ coverage.xml : $(shell find lambda_gateway tests -name '* .py')
2121 flake8 $^
2222 pytest
2323
Original file line number Diff line number Diff line change 11import asyncio
2+ import importlib
23import json
34import os
4- from importlib . util import ( spec_from_file_location , module_from_spec )
5+ import sys
56
67from lambda_gateway import (lambda_context , logger )
78
@@ -23,12 +24,11 @@ def get_handler(self):
2324 if not name :
2425 raise ValueError (f"Bad handler signature '{ self .handler } '" )
2526 try :
26- pypath = os .path .join (os .path .curdir , f'{ name } .py' )
27- spec = spec_from_file_location (name , pypath )
28- module = module_from_spec (spec )
29- spec .loader .exec_module (module )
30- return getattr (module , func )
31- except FileNotFoundError :
27+ sys .path .append (os .path .curdir )
28+ module = importlib .import_module (name )
29+ handler = getattr (module , func )
30+ return handler
31+ except ModuleNotFoundError :
3232 raise ValueError (f"Unable to import module '{ name } '" )
3333 except AttributeError :
3434 raise ValueError (f"Handler '{ func } ' missing on module '{ name } '" )
You can’t perform that action at this time.
0 commit comments