iopipe / iopipe-python

Python agent for AWS Lambda metrics, tracing, profiling & analytics
https://www.iopipe.com
Apache License 2.0
79 stars 17 forks source link

Usage example not working on AWS Python 3.6 #249

Open XerTheSquirrel opened 6 years ago

XerTheSquirrel commented 6 years ago

Description

Following the README, the minimalist sample does not seem to work at all on Python 3.6. The README does say "This package supports Python 2.7 and 3.6, the runtimes supported by AWS Lambda.".

Steps to reproduce the issue:

  1. Setup new Lambda.
  2. Choose Python 3.6
  3. Follow https://github.com/iopipe/iopipe-python#installation
  4. Follow https://github.com/iopipe/iopipe-python#usage
  5. Create index.py
  6. Place as contents:
    
    from iopipe import IOpipe
    iopipe = IOpipe('token')

@iopipe def lambda_handler(event, context): pass

7. Set entry point to: `index.lambda_handler`
8. Save it
9. Test it with anything

**Describe the results you received:**

Response: { "errorMessage": "Syntax error in module 'index'" }

Request ID: "102bedeb-86bf-11e8-8562-97ea3fe2926e"

Function Logs: START RequestId: 102bedeb-86bf-11e8-8562-97ea3fe2926e Version: $LATEST Syntax error in module 'index': invalid syntax (_base.py, line 414)

END RequestId: 102bedeb-86bf-11e8-8562-97ea3fe2926e REPORT RequestId: 102bedeb-86bf-11e8-8562-97ea3fe2926e Duration: 0.83 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 22 MB



**Describe the results you expected:**

Expected the lambda to pass.

**Additional information you deem important (e.g. issue happens only occasionally):**

Switching to Python 2.7 works.
kolanos commented 5 years ago

@XerTheSquirrel This line:

Syntax error in module 'index': invalid syntax (_base.py, line 414)

Appears to be referencing AWS Lambda's own bootstrap system. There is no _base.py in the iopipe module.

kolanos commented 5 years ago

Closing as unable to reproduce.

mateusfccp commented 5 years ago

I'm also having this problem with my application. It was running stable on production for almost a year and suddenly, in a new deploy, it started to throw this error.

pramodsetlur commented 5 years ago

I am seeing the issue as well.

kolanos commented 5 years ago

@pramodsetlur, @mateusfccp Any details to help reproduce? Are you both getting the same traceback? Is this with Serverless or something else?

kolanos commented 5 years ago

@pramodsetlur, @mateusfccp Is the futures package installed? IOpipe installs a futures package on python2.7 which is a backport of concurrent.futures which is only available in python3.x. However, if you are running python2.7 locally and install IOpipe and then deploy to python3.6 the futures package will be included which may result in this error. Solution is to ensure that futures is not included in your python3.6 deployment.

pramodsetlur commented 5 years ago

@kolanos Apologies; I am not using iopipie; My error is more related just to Lambda. I am deploying with serverless. It runs successfully with 3.7 on local and crashes with the same error Syntax error in module 'index': invalid syntax (_base.py, line 414) on Lambda 3.6. I changed it to 2.7 and it worked fine. (So, my message might not be relevant to iopipe at all.)

kolanos commented 4 years ago

@pramodsetlur I traced the invalid syntax (_base.py, line 414) back to the futures backport. So it is possible you're still running into that issue even without IOpipe being present.

kolanos commented 4 years ago

@pramodsetlur If you're willing to give IOpipe another try, we have a new layers plugin for Serverless that doesn't require a code change: https://github.com/iopipe/serverless-iopipe-layers

pramodsetlur commented 4 years ago

@kolanos I only commented on this issue because i was seeing the particular error in _base.py. Was never using iopipie. But appreciate the responses.

jonahjon commented 4 years ago

The fix for this is to change either

  1. Use pip3 install for lambda runtimes of 3.X
  2. Delete the folder in your packaged concurrent/futures/
kolanos commented 4 years ago

Going to add this to a troubleshooting section in the README.