aws / aws/aws-xray-sdk-python

Instrumented Python3.6 Lambda Functions return Missing Module: Queue error in Console

Open
#165 5 comments 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
338
Forks
147
PR merge metrics
No merged PRs in 30d

Description

Previously, I had a working function in Python 3.6 below that I built by installing Boto3 and Botocore and packaging it up. No errors running in Python 3.6
```python
import boto3
import json

def handler(event,context):
client = boto3.client('ce')
s3 = boto3.resource('s3')
--- Python Code Shortened ---
object.put(Body=json.dumps(response).encode())
return str (response)
```

Decided to add instrumentation to the Function, enabled X-Ray in the Console, attached needed IAM permissions and packaged the new function with aws-xray-sdk as well as multiprocessing due to having `Missing Module: Queue` error the first time.
```python
import boto3
import json
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch

patch(['boto3'])
@xray_recorder.capture("handler")

def handler(event,context):
client = boto3.client('ce')
s3 = boto3.resource('s3')
--- Python Code Shortened ---
```

Continued to receive `Missing Module: Queue` error -- which does not make a whole lot of sense since Python 3.x+ has renamed it `queue` and it is included in the `multiprocessing` library. I now changed the beginning of the code to this
```python
import boto3
import json
try:
import queue
except ImportError:
import Queue as queue

from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch
```

I have also tried the above as
```python
try:
import Queue
except ImportError:
import Queue as queue
```

However, I am still facing the issue of `Missing Module: Queue` -- is this a known issue for working with the automated decorator in X-Ray with Lambda? Is there another library I can try adding?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.