File tree 2 files changed +10
-10
lines changed
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
2
2
SLEEP := 0
3
3
TIMEOUT := 3
4
4
5
- .PHONY : default clean test up upload
5
+ .PHONY : all clean test up upload
6
6
7
- default : $(SDIST )
7
+ all : $(SDIST )
8
8
9
9
clean :
10
10
rm -rf dist
@@ -17,7 +17,7 @@ upload: $(SDIST)
17
17
up :
18
18
SLEEP=$(SLEEP ) python -m lambda_gateway -t $(TIMEOUT ) lambda_function.lambda_handler
19
19
20
- coverage.xml : $(shell find . -name '* .py' -not -path './. * ')
20
+ coverage.xml : $(shell find lambda_gateway tests -name '* .py')
21
21
flake8 $^
22
22
pytest
23
23
Original file line number Diff line number Diff line change 1
1
import asyncio
2
+ import importlib
2
3
import json
3
4
import os
4
- from importlib . util import ( spec_from_file_location , module_from_spec )
5
+ import sys
5
6
6
7
from lambda_gateway import (lambda_context , logger )
7
8
@@ -23,12 +24,11 @@ def get_handler(self):
23
24
if not name :
24
25
raise ValueError (f"Bad handler signature '{ self .handler } '" )
25
26
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 :
32
32
raise ValueError (f"Unable to import module '{ name } '" )
33
33
except AttributeError :
34
34
raise ValueError (f"Handler '{ func } ' missing on module '{ name } '" )
You can’t perform that action at this time.
0 commit comments