This is an automated email from the ASF dual-hosted git repository.

jrmccluskey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 38f6c5f309e [Go SDK] Switch sampler to use ticker instead of sleep. 
(#26505)
38f6c5f309e is described below

commit 38f6c5f309e4d3101e575ab70b14f7e6964a45bc
Author: Robert Burke <[email protected]>
AuthorDate: Tue May 9 08:33:59 2023 -0700

    [Go SDK] Switch sampler to use ticker instead of sleep. (#26505)
    
    Co-authored-by: lostluck <[email protected]>
---
 sdks/go/pkg/beam/core/runtime/harness/sampler.go | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sdks/go/pkg/beam/core/runtime/harness/sampler.go 
b/sdks/go/pkg/beam/core/runtime/harness/sampler.go
index 99ec4e6db88..5246c1fe69c 100644
--- a/sdks/go/pkg/beam/core/runtime/harness/sampler.go
+++ b/sdks/go/pkg/beam/core/runtime/harness/sampler.go
@@ -32,15 +32,16 @@ func newSampler(store *metrics.Store) *stateSampler {
 }
 
 func (s *stateSampler) start(ctx context.Context, t time.Duration) {
+       ticker := time.NewTicker(t)
+       defer ticker.Stop()
        for {
                select {
                case <-s.done:
                        return
                case <-ctx.Done():
                        return
-               default:
+               case <-ticker.C:
                        s.sampler.Sample(ctx, t)
-                       time.Sleep(t)
                }
        }
 }

Reply via email to