Skip to content

Commit

Permalink
Create RLock() early to avoid exception at shutdown (#351)
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
  • Loading branch information
sloretz authored May 17, 2019
1 parent da5fc80 commit b8217b6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rclpy/rclpy/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def __init__(self, pycapsule):
self.__request_invalidation = False
self.__valid = True
self.__rlock = RLock()
# Create this early because RLock() can raise during interpeter shutdown
self.__dependents_rlock = RLock()
self.__required_handles = []
self.__dependent_handles = weakref.WeakSet()
self.__destroy_callbacks = []
Expand Down Expand Up @@ -157,7 +159,7 @@ def __destroy(self):

def __destroy_dependents(self, then):
# assumes self.__rlock is held
deps_lock = RLock()
deps_lock = self.__dependents_rlock
# Turn weak references to regular references
dependent_handles = [dep for dep in self.__dependent_handles]

Expand Down

0 comments on commit b8217b6

Please sign in to comment.