AttributeError: 'NoneType' object has no attribute 'close'
issue details
Exception in thread /iiwa/joint_states:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_pubsub.py", line 185, in robust_connect_subscriber
conn.receive_loop(receive_cb)
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_base.py", line 846, in receive_loop
self.close()
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/impl/tcpros_base.py", line 858, in close
self.socket.close()
AttributeError: 'NoneType' object has no attribute 'close'
The above error raised when I subscribe a topic in a sub-thread (python), and init_node
is defined in main-thread.
main thread:
rospy.init_node('node_name')
sub thread:
js = rospy.wait_for_message('/iiwa/joint_states', JointState, timeout=5)
Similar issue can be found at:
Debugging - TCP/IP connection failed errors
I think it is the multi-thread caused the problem, workaround in ros_comm/issues/2212 can't be applied in my case directly.
BTW, this error raised only occasionally, and I can publish other topic in sub thread normally without any problem.
I can publish topic in sub
Thanks in advance!