Instrumented Python3.6 Lambda Functions return Missing Module: Queue error in Console
- Vorherrschende Sprache
- Python
- Sterne
- 339
- Forks
- 147
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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?
Beitragsleitfaden
Rechercherichtung
Es wird keine Repository-Datei oder kein Test genannt. Beginne damit, das Lambda-Paket für Python 3.6 mit aws-xray-sdk und boto3 zu reproduzieren, wobei der automatisierte Decorator und der Pfad `Missing Module: Queue` im Mittelpunkt stehen; abgeschlossen ist die Aufgabe, wenn die instrumentierte Funktion ohne diesen Konsolenfehler ausgeführt wird und die Ursache durch eine geeignete Änderung am Repository oder einen Test abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, python
- Bereich
- cloud, observability-sre
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100