Hi,
it's really hard to guess what you are doing without some more context ( code...) . The broken pipe is typical if some connection is forcefully terminated from one end, so not too surprising your case.
One hint: the gerrit server-side hooks should be fast, if you want to to long-running things (like running a test suite) then you should reconsider your general
approach to let the hook just send a trigger to some external job that then sets the appropriate labels.
Björn