Python module failing in 'Tutorial: Develop and deploy a Python IoT Edge module using Linux containers'

George Hill 1 Reputation point
2021-11-24T01:33:30.03+00:00

I've followed the instructions in Tutorial: Develop and deploy a Python IoT Edge module using Linux containers and all works fine EXCEPT that I can't get the Python module to run. I keep getting the following error message (even though I've copied the main.py code from the Tutorial)

IoT Hub Client for Python
./main.py:66: RuntimeWarning: coroutine 'execute_patch_for_async.<locals>.shutdown' was never awaited
client.shutdown()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "./main.py", line 115, in <module>
main()
File "./main.py", line 85, in main
client = create_client()
File "./main.py", line 63, in create_client
client.on_message_received = receive_message_handler
NameError: name 'receive_message_handler' is not defined

Attached is the main.py code that I'm using.151966-mainpy.txt

@AshokPeddakotla-MSFT ?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
598 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,761 Reputation points MVP Volunteer Moderator
    2021-11-25T10:56:23.147+00:00

    Hello @George Hill ,

    I have created a new VS Code project based on the VS Code Azure IoT Edge extension, python template.

    I use a Windows device with Docker CE installed and WSL2 underneath.

    I was able to build and deploy the module:

    152517-image.png

    My container is available here on docker hub.

    I deployed to an edge device:

    152575-image.png

    it was deployed successfully:

    152584-image.png

    It runs already for 20 minutes:

    152539-image.png

    I compared my main.py (my project is available on github) with yours but there are no differences.

    You can try to deploy my docker hub module. You can also try to compile and deploy my project.

    This should give you a starting point for a successful deployment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.