From fc7edc5c8089488cb50bc801788ae16949d855c4 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 30 Jun 2023 01:05:18 +0800 Subject: [PATCH] grid2: call TryLock in updateGridNumOfOrdersMetricsWithLock --- pkg/strategy/grid2/strategy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index f9111c5c2..11abe0f7b 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -1179,7 +1179,11 @@ func (s *Strategy) updateFilledOrderMetrics(order types.Order) { } func (s *Strategy) updateGridNumOfOrdersMetricsWithLock() { - s.updateGridNumOfOrdersMetrics(s.getGrid()) + if s.mu.TryLock() { + grid := s.grid + s.mu.Unlock() + s.updateGridNumOfOrdersMetrics(grid) + } } func (s *Strategy) updateGridNumOfOrdersMetrics(grid *Grid) {