File tree Expand file tree Collapse file tree
cuda_core/cuda/core/experimental Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,5 +10,4 @@ cdef class Event:
1010 int _device_id
1111 object _ctx_handle
1212
13- cdef _shutdown_safe_close(self , is_shutting_down = * )
1413 cpdef close(self )
Original file line number Diff line number Diff line change @@ -20,9 +20,7 @@ from cuda.core.experimental._context import Context
2020from cuda.core.experimental._utils.cuda_utils import (
2121 CUDAError,
2222 driver,
23- handle_return,
2423)
25- import sys
2624if TYPE_CHECKING:
2725 import cuda.bindings
2826 from cuda.core.experimental._device import Device
@@ -108,20 +106,15 @@ cdef class Event:
108106 self ._ctx_handle = ctx_handle
109107 return self
110108
111- cdef _shutdown_safe_close(self , is_shutting_down = sys.is_finalizing):
112- if is_shutting_down and is_shutting_down():
113- return
109+ cpdef close(self ):
110+ """ Destroy the event."""
114111 if self ._handle != NULL :
115112 with nogil:
116113 HANDLE_RETURN(cydriver.cuEventDestroy(self ._handle))
117114 self ._handle = < cydriver.CUevent> (NULL )
118115
119- cpdef close(self ):
120- """ Destroy the event."""
121- self ._shutdown_safe_close(is_shutting_down = None )
122-
123- def __del__ (self ):
124- self ._shutdown_safe_close()
116+ def __dealloc__ (self ):
117+ self .close()
125118
126119 def __isub__ (self , other ):
127120 return NotImplemented
Original file line number Diff line number Diff line change @@ -14,8 +14,6 @@ from cuda.core.experimental._utils.cuda_utils cimport (
1414 HANDLE_RETURN,
1515)
1616
17- import sys
18-
1917import cython
2018import os
2119import warnings
@@ -202,12 +200,15 @@ cdef class Stream:
202200 return self
203201
204202 def __del__ (self ):
205- self ._shutdown_safe_close()
203+ self .close()
204+
205+ cpdef close(self ):
206+ """ Destroy the stream.
206207
207- cdef _shutdown_safe_close(self , is_shutting_down = sys.is_finalizing):
208- if is_shutting_down and is_shutting_down():
209- return
208+ Destroy the stream if we own it. Borrowed foreign stream
209+ object will instead have their references released.
210210
211+ """
211212 if self ._owner is None :
212213 if self ._handle and not self ._builtin:
213214 with nogil:
@@ -216,15 +217,6 @@ cdef class Stream:
216217 self ._owner = None
217218 self ._handle = < cydriver.CUstream> (NULL )
218219
219- cpdef close(self ):
220- """ Destroy the stream.
221-
222- Destroy the stream if we own it. Borrowed foreign stream
223- object will instead have their references released.
224-
225- """
226- self ._shutdown_safe_close(is_shutting_down = None )
227-
228220 def __cuda_stream__ (self ) -> tuple[int , int]:
229221 """Return an instance of a __cuda_stream__ protocol."""
230222 return (0, int(self.handle ))
You can’t perform that action at this time.
0 commit comments