Skip to content

Commit 4895b62

Browse files
Merge pull request #221398 from kgremban/dec13-hub102379
Add variable instance
2 parents 68dd223 + 6bdb9b0 commit 4895b62

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

articles/iot-hub/iot-hub-python-python-module-twin-getstarted.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -197,37 +197,40 @@ In this section, you create a Python app to get the module twin desired properti
197197
198198
1. Add the following code to your Python file. Replace *YourModuleConnectionString* with the module connection string you copied in step 1.
199199
200-
```python
201-
import time
202-
from azure.iot.device import IoTHubModuleClient
200+
```python
201+
import time
202+
from azure.iot.device import IoTHubModuleClient
203203
204-
def twin_patch_handler(twin_patch):
205-
print("")
206-
print("Twin desired properties patch received:")
207-
print(twin_patch)
204+
CONNECTION_STRING = "YourIotHubConnectionString"
208205
209206
210-
def main():
211-
print ("Starting the IoT Hub Python sample...")
212-
client = IoTHubModuleClient.create_from_connection_string(CONNECTION_STRING)
207+
def twin_patch_handler(twin_patch):
208+
print("")
209+
print("Twin desired properties patch received:")
210+
print(twin_patch)
213211
214-
print ("Waiting for commands, press Ctrl-C to exit")
215-
try:
216-
# Attach the handler to the client
217-
client.on_twin_desired_properties_patch_received = twin_patch_handler
218-
219-
while True:
220-
time.sleep(1000)
221-
except KeyboardInterrupt:
222-
print("IoTHubModuleClient sample stopped")
223-
finally:
224-
# Graceful exit
225-
print("Shutting down IoT Hub Client")
226-
client.shutdown()
227-
228-
if __name__ == '__main__':
229-
main()
230-
```
212+
213+
def main():
214+
print ("Starting the IoT Hub Python sample...")
215+
client = IoTHubModuleClient.create_from_connection_string(CONNECTION_STRING)
216+
217+
print ("Waiting for commands, press Ctrl-C to exit")
218+
try:
219+
# Attach the handler to the client
220+
client.on_twin_desired_properties_patch_received = twin_patch_handler
221+
222+
while True:
223+
time.sleep(1000)
224+
except KeyboardInterrupt:
225+
print("IoTHubModuleClient sample stopped")
226+
finally:
227+
# Graceful exit
228+
print("Shutting down IoT Hub Client")
229+
client.shutdown()
230+
231+
if __name__ == '__main__':
232+
main()
233+
```
231234

232235
## Run the apps
233236

0 commit comments

Comments
 (0)