Skip to content

Commit 04f0cf7

Browse files
committed
fix CI errors
1 parent b015e3a commit 04f0cf7

4 files changed

Lines changed: 18 additions & 16 deletions

File tree

awscrt/mqtt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class Connection(NativeResource):
334334
335335
enable_metrics (bool): Enable IoT SDK metrics in MQTT CONNECT packet username field, including SDK name, version, and platform. Default to True.
336336
337-
metrics (Optional[AWSIoTMetrics]) : Optional metrics configuration for IoT SDK metrics reporting. If provided, the CRT will use the given metrics. If None, a default AWSIoTMetrics will be created.
337+
metrics (Optional[:class: `AWSIoTMetrics`]) : Optional metrics configuration for IoT SDK metrics reporting. If provided, the CRT will use the given metrics. If None, a default AWSIoTMetrics will be created.
338338
"""
339339

340340
def __init__(self,

awscrt/mqtt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ class ClientOptions:
13721372
on_lifecycle_event_connection_failure_fn (Callable[[LifecycleConnectFailureData],]): Callback for Lifecycle Event Connection Failure.
13731373
on_lifecycle_event_disconnection_fn (Callable[[LifecycleDisconnectData],]): Callback for Lifecycle Event Disconnection.
13741374
enable_metrics (bool): Enable IoT SDK metrics in MQTT CONNECT packet username field, including SDK name, version, and platform. Default to True.
1375-
metrics (Optional[AWSIoTMetrics]) : Optional metrics configuration for IoT SDK metrics reporting. If provided, the CRT will use the given metrics. If None, a default AWSIoTMetrics will be created.
1375+
metrics (Optional[:class: `AWSIoTMetrics`]) : Optional metrics configuration for IoT SDK metrics reporting. If provided, the CRT will use the given metrics. If None, a default AWSIoTMetrics will be created.
13761376
13771377
"""
13781378
host_name: str

source/mqtt5_client.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@ PyObject *aws_py_mqtt5_client_new(PyObject *self, PyObject *args) {
974974
AWS_ZERO_STRUCT(tls_options);
975975
struct aws_mqtt5_user_property *user_properties_tmp = NULL;
976976
struct aws_mqtt5_user_property *will_user_properties_tmp = NULL;
977+
struct aws_mqtt_metadata_entry *metadata_entries = NULL;
978+
PyObject *library_name_py = NULL;
979+
PyObject *metadata_entries_py = NULL;
977980

978981
struct aws_mqtt5_client_options client_options;
979982
AWS_ZERO_STRUCT(client_options);
@@ -1320,9 +1323,7 @@ PyObject *aws_py_mqtt5_client_new(PyObject *self, PyObject *args) {
13201323
/* METRICS */
13211324
struct aws_mqtt_iot_metrics metrics_tmp;
13221325
AWS_ZERO_STRUCT(metrics_tmp);
1323-
struct aws_mqtt_metadata_entry *metadata_entries = NULL;
1324-
PyObject *library_name_py = NULL;
1325-
PyObject *metadata_entries_py = NULL;
1326+
13261327
if (PyObject_IsTrue(is_metrics_enabled_py) && metrics_py != Py_None) {
13271328
library_name_py = PyObject_GetAttrString(metrics_py, "library_name");
13281329
metrics_tmp.library_name = aws_byte_cursor_from_pyunicode(library_name_py);

source/mqtt_client_connection.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,16 +447,20 @@ static bool s_set_metrics(struct aws_mqtt_client_connection *connection, PyObjec
447447

448448
bool success = false;
449449

450+
struct aws_mqtt_iot_metrics metrics_tmp;
451+
AWS_ZERO_STRUCT(metrics_tmp);
452+
PyObject *metadata_entries_py = NULL;
453+
struct aws_mqtt_metadata_entry *metadata_entries = NULL;
454+
size_t metadata_count = 0;
455+
450456
PyObject *library_name_py = PyObject_GetAttrString(metrics, "library_name");
451-
struct aws_byte_cursor library_name = aws_byte_cursor_from_pyunicode(library_name_py);
452-
if (!library_name.ptr) {
457+
metrics_tmp.library_name = aws_byte_cursor_from_pyunicode(library_name_py);
458+
if (!metrics_tmp.library_name.ptr) {
453459
PyErr_SetString(PyExc_TypeError, "metrics.library_name must be str type");
454460
goto done;
455461
}
456462

457-
PyObject *metadata_entries_py = PyObject_GetAttrString(metrics, "metadata_entries");
458-
struct aws_mqtt_metadata_entry *metadata_entries = NULL;
459-
size_t metadata_count = 0;
463+
metadata_entries_py = PyObject_GetAttrString(metrics, "metadata_entries");
460464

461465
if (metadata_entries_py && metadata_entries_py != Py_None && PyList_Check(metadata_entries_py)) {
462466
Py_ssize_t count = PyList_Size(metadata_entries_py);
@@ -488,13 +492,10 @@ static bool s_set_metrics(struct aws_mqtt_client_connection *connection, PyObjec
488492
}
489493
}
490494

491-
struct aws_mqtt_iot_metrics metrics_struct = {
492-
.library_name = library_name,
493-
.metadata_count = metadata_count,
494-
.metadata_entries = metadata_entries,
495-
};
495+
metrics_tmp.metadata_count = metadata_count;
496+
metrics_tmp.metadata_entries = metadata_entries;
496497

497-
if (aws_mqtt_client_connection_set_metrics(connection, &metrics_struct)) {
498+
if (aws_mqtt_client_connection_set_metrics(connection, &metrics_tmp)) {
498499
PyErr_SetAwsLastError();
499500
goto done;
500501
}

0 commit comments

Comments
 (0)