Content-Length: 430572 | pFad | http://github.com/HDE/python-lambda-local/pull/7/files

42 release v0.1.3 by yxd-hde · Pull Request #7 · HDE/python-lambda-local · GitHub
Skip to content

release v0.1.3 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ Version 0.1.2
-------------

- Add more commandline options.

Version 0.1.3
-------------

- Exit with non-zero code when execution of function fails.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# python-lambda-local

[![Join the chat at https://gitter.im/HDE/python-lambda-local](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![wercker status](https://app.wercker.com/status/04f5bc5b7de3d5c6f13eb5b871035226/s "wercker status")](https://app.wercker.com/project/bykey/04f5bc5b7de3d5c6f13eb5b871035226)

Run lambda function on local machine

Expand Down
13 changes: 6 additions & 7 deletions lambda_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@

def main():
args = parse_args()
try:
p = Process(target=run, args=(args,))
p.start()
p.join()
except:
e = sys.exc_info()
print(e[1])

p = Process(target=run, args=(args,))
p.start()
p.join()

sys.exit(p.exitcode)


def parse_args():
Expand Down
22 changes: 16 additions & 6 deletions lambda_local/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
urllib3.disable_warnings()


ERR_TYPE_EXCEPTION = 0
ERR_TYPE_TIMEOUT = 1

EXITCODE_ERR = 1


def run(args):
e = event.read_event(args.event)
c = context.Context(args.timeout, args.arn_string, args.version_name)
Expand All @@ -40,10 +46,7 @@ def run(args):
logger.info("START RequestId: {}".format(request_id))

start_time = timeit.default_timer()
try:
result = execute(func, e, c)
except TimeoutException as te:
result = te
result, err_type = execute(func, e, c)
end_time = timeit.default_timer()

logger.info("END RequestId: {}".format(request_id))
Expand All @@ -57,6 +60,9 @@ def run(args):
logger.info("REPORT RequestId: {}\tDuration: {}".format(
request_id, duration))

if err_type is not None:
sys.exit(EXITCODE_ERR)


def load_lib(path):
sys.path.append(os.path.abspath(path))
Expand All @@ -75,17 +81,21 @@ def load(request_id, path, function_name):


def execute(func, event, context):
err_type = None

try:
with time_limit(context.timeout):
result = func(event, context.activate())
except TimeoutException as err:
raise err
result = err
err_type = ERR_TYPE_TIMEOUT
except:
err = sys.exc_info()
result = json.dumps({
"errorMessage": str(err[1]),
"stackTrace": traceback.extract_tb(err[2]),
"errorType": err[0].__name__
}, indent=4, separators=(',', ': '))
err_type = ERR_TYPE_EXCEPTION

return result
return result, err_type
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run_tests(self):
sys.exit(pytest.main(self.test_args))


version = "0.1.2"
version = "0.1.3"

setup(name="python-lambda-local",
version=version,
Expand Down
5 changes: 5 additions & 0 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ box: python:2.7-slim

build:
steps:
- script:
name: virtualenv install
code: |
pip install virtualenv

- virtualenv:
name: setup virtual environment
install_wheel: true # Enable wheel to speed up builds (experimental)
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/HDE/python-lambda-local/pull/7/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy