File tree Expand file tree Collapse file tree
src/hiero_sdk_python/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,19 +19,29 @@ def __init__(self):
1919
2020 def _set_call (self , call : Any ):
2121 """Sets the active gRPC call so it can be cancelled."""
22+ should_cancel = False
23+
2224 with self ._lock :
2325 self ._call = call
2426
25- if self ._cancelled .is_set ():
26- self ._call .cancel ()
27+ if call is not None and self ._cancelled .is_set ():
28+ should_cancel = True
29+
30+ if should_cancel :
31+ self ._call .cancel ()
2732
2833 def cancel (self ):
2934 """Signals to cancel the subscription."""
35+ should_cancel = False
36+
3037 with self ._lock :
3138 self ._cancelled .set ()
3239
33- if self ._call :
34- self ._call .cancel ()
40+ if self ._call is not None :
41+ should_cancel = True
42+
43+ if should_cancel :
44+ self ._call .cancel ()
3545
3646 def is_cancelled (self ) -> bool :
3747 """Returns True if this subscription is already cancelled."""
You can’t perform that action at this time.
0 commit comments