Skip to content

ResouceWarning on Python 3.14 from unclosed tempfile.NamedTemporaryFile #1134

@mroeschke

Description

@mroeschke
import warnings
 
import numpy as np
import stumpy

with warnings.catch_warnings():
    warnings.filterwarnings("error", category=ResourceWarning)

    rng = np.random.default_rng(42)
    your_time_series = rng.random(10000)
    window_size = (
        50  # Approximately, how many data points might be found in a pattern
    )
    stumpy.gpu_stump(your_time_series, m=window_size, device_id=0)

Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp1ardm6k6'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmpwze200r5'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmphuv6pm3j'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp4_v59e8o'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmpuom17x__'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp2r10jnt6'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmphejxa2ki'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmpv50nsq6c'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp88ucwns2'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmpgw8vwrs6'>>
/miniforge3/envs/test-stumpy/lib/python3.14/site-packages/numba/cuda/dispatcher.py:536: NumbaPerformanceWarning: Grid size 20 will likely result in GPU under-utilization due to low occupancy.
  warn(NumbaPerformanceWarning(msg))
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp_ev3_olu'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmpbr37tx23'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp4jdjzhyl'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp2x6jukyf'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmp2_79_g0d'>>
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x7932ed931590>:
Traceback (most recent call last):
  File "/miniforge3/envs/test-stumpy/lib/python3.14/tempfile.py", line 484, in __del__
    _warnings.warn(self.warn_message, ResourceWarning)
ResourceWarning: Implicitly cleaning up <_TemporaryFileWrapper file=<_io.BufferedRandom name='/tmp/tmpgrv1ipxp'>>
mparray([[6.863254359622374, 3181, -1, 3181],
         [6.64154485072902, 3182, -1, 3182],
         [6.830177331061536, 3183, -1, 3183],
         ...,
         [6.960611650535677, 970, 970, -1],
         [6.97346754087878, 971, 971, -1],
         [6.800287895530834, 972, 972, -1]], shape=(9951, 4), dtype=object)

I believe this call is creating a temporary file that is never closed

fname = tempfile.NamedTemporaryFile(delete=False)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions