Close command socket after sending stop
After sending the stop signal to the command socket it should be closed explicitly. Otherwise a resource warning [1] is emitted to stderr. [1]: Resource warning: (...)/zuul/executor/server.py:644: ResourceWarning: unclosed <socket.socket fd=24, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0, raddr=(...)/executor.socket> self.command_socket.stop() Change-Id: I0e85ea9f5021e329abf825afbd8e29d134c08669
This commit is contained in:
parent
6fcf115d02
commit
03b41eecd5
|
@ -44,9 +44,9 @@ class CommandSocket(object):
|
|||
# First, wake up our listener thread with a connection and
|
||||
# tell it to stop running.
|
||||
self.running = False
|
||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
s.connect(self.path)
|
||||
s.sendall(b'_stop\n')
|
||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
|
||||
s.connect(self.path)
|
||||
s.sendall(b'_stop\n')
|
||||
# The command '_stop' will be ignored by our listener, so
|
||||
# directly inject it into the queue so that consumers of this
|
||||
# class which are waiting in .get() are awakened. They can
|
||||
|
|
Loading…
Reference in New Issue