pbacsko commented on code in PR #811:
URL: https://github.com/apache/yunikorn-k8shim/pull/811#discussion_r1546947478


##########
pkg/dispatcher/dispatcher.go:
##########
@@ -257,13 +260,23 @@ func Stop() {
        }
 
        close(getDispatcher().stopChan)
-       maxTimeout := 5
-       for getDispatcher().isRunning() && maxTimeout > 0 {
-               log.Log(log.ShimDispatcher).Info("waiting for dispatcher to be 
stopped",
-                       zap.Int("remainingSeconds", maxTimeout))
-               time.Sleep(1 * time.Second)
-               maxTimeout--
+       stopWait := make(chan struct{})
+       defer close(stopWait)
+
+       go func() {
+               getDispatcher().stopped.Wait()
+               stopWait <- struct{}{}

Review Comment:
   > pardon me. why it causes double closure if we remove the close(stopWait) 
from Stop().
   
   In that case it doesn't. I just checked and a general principle is that 
channel shouldn't be closed on a receiver side. I don't think it's a big deal, 
but ok, I'll change it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to