Skip to content

Commit 0f0c8df

Browse files
subscription: name subscription tasks
It makes asyncio task debugging simpler. Signed-off-by: Samuel Gauthier <[email protected]>
1 parent e5817f1 commit 0f0c8df

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

sysrepo/subscription.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def module_change_callback(session, sub_id, module, xpath, event, req_id, priv):
265265
)
266266
)
267267
task = subscription.loop.create_task(
268-
callback(event_name, req_id, changes, private_data, **extra_info)
268+
callback(event_name, req_id, changes, private_data, **extra_info),
269+
name=f"sr-module-change-{event_name}-{req_id}-{xpath}",
269270
)
270271
task.add_done_callback(
271272
functools.partial(subscription.task_done, task_id, event_name)
@@ -379,7 +380,8 @@ def oper_data_callback(session, sub_id, module, xpath, req_xpath, req_id, parent
379380

380381
if task_id not in subscription.tasks:
381382
task = subscription.loop.create_task(
382-
callback(req_xpath, private_data, **extra_info)
383+
callback(req_xpath, private_data, **extra_info),
384+
name=f"sr-oper-data-{req_id}-{xpath}",
383385
)
384386
task.add_done_callback(
385387
functools.partial(subscription.task_done, task_id, "oper")
@@ -502,7 +504,8 @@ def rpc_callback(session, sub_id, xpath, input_node, event, req_id, output_node,
502504

503505
if task_id not in subscription.tasks:
504506
task = subscription.loop.create_task(
505-
callback(xpath, input_dict, event_name, private_data, **extra_info)
507+
callback(xpath, input_dict, event_name, private_data, **extra_info),
508+
name=f"sr-rpc-{xpath}",
506509
)
507510
task.add_done_callback(
508511
functools.partial(subscription.task_done, task_id, event_name)
@@ -624,7 +627,13 @@ def event_notif_tree_callback(session, sub_id, notif_type, notif, timestamp, pri
624627
if is_async_func(callback):
625628
task = subscription.loop.create_task(
626629
callback(
627-
xpath, notif_type, notif_dict, timestamp, private_data, **extra_info
630+
xpath,
631+
notif_type,
632+
notif_dict,
633+
timestamp,
634+
private_data,
635+
**extra_info,
636+
name=f"sr-rpc-event-notif-{xpath}",
628637
)
629638
)
630639
task.add_done_callback(

0 commit comments

Comments
 (0)