Skip to content

Commit d909a71

Browse files
committed
Address peer review comment
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
1 parent c2f71b5 commit d909a71

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

rclpy/rclpy/context.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Context:
3636
def __init__(self):
3737
self._lock = threading.Lock()
3838
self._callbacks = []
39-
self._callbacks_lock = threading.Lock()
4039
self._logging_initialized = False
4140

4241
@property
@@ -89,12 +88,11 @@ def ok(self):
8988
return False
9089

9190
def _call_on_shutdown_callbacks(self):
92-
with self._callbacks_lock:
93-
for weak_method in self._callbacks:
94-
callback = weak_method()
95-
if callback is not None:
96-
callback()
97-
self._callbacks = []
91+
for weak_method in self._callbacks:
92+
callback = weak_method()
93+
if callback is not None:
94+
callback()
95+
self._callbacks = []
9896

9997
def shutdown(self):
10098
"""Shutdown this context."""
@@ -124,8 +122,7 @@ def on_shutdown(self, callback: Callable[[], None]):
124122
if not self.__context.ok():
125123
callback()
126124
else:
127-
with self._callbacks_lock:
128-
self._callbacks.append(weakref.WeakMethod(callback, self._remove_callback))
125+
self._callbacks.append(weakref.WeakMethod(callback, self._remove_callback))
129126

130127
def _logging_fini(self):
131128
# This function must be called with self._lock held.

0 commit comments

Comments
 (0)