Skip to content

test_concurrent_cwt failure on macOS arm64 with free-threaded CPython #758

Closed
@rgommers

Description

@rgommers

We have a set of concurrent tests that use concurrent.futures.ThreadPoolExecutor. It has never failed before AFAIK; the tests also passed a number of times already with the new Linux free-threaded CI. It just now failed for the first time in the macOS arm64 free-threaded wheel build job (from the CI log):

_____________________________ test_concurrent_cwt ______________________________
  
      @uses_futures
      def test_concurrent_cwt():
          atol = rtol = 1e-14
          time, sst = pywt.data.nino()
          dt = time[1]-time[0]
          transform = partial(pywt.cwt, scales=np.arange(1, 4), wavelet='cmor1.5-1',
                              sampling_period=dt)
          for _ in range(10):
              arrs = [sst.copy() for _ in range(50)]
              with futures.ThreadPoolExecutor(max_workers=max_workers) as ex:
  >               results = list(ex.map(transform, arrs))

...

   ../venv-test-arm64/lib/python3.13/site-packages/pywt/tests/test_concurrent.py:101: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  /Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py:619: in result_iterator
      yield _result_or_cancel(fs.pop())
  /Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py:317: in _result_or_cancel
      return fut.result(timeout)
  /Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py:456: in result
      return self.__get_result()
  /Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py:401: in __get_result
      raise self._exception
  /Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py:58: in run
      result = self.fn(*self.args, **self.kwargs)
  ../venv-test-arm64/lib/python3.13/site-packages/pywt/_cwt.py:202: in cwt
      frequencies = scale2frequency(wavelet, scales, precision)
  ../venv-test-arm64/lib/python3.13/site-packages/pywt/_functions.py:183: in scale2frequency
      return central_frequency(wavelet, precision=precision) / scale
...
          index = np.argmax(abs(fft(psi)[1:])) + 2
  >       if index > len(psi) / 2:
  E       TypeError: A loop/promoter has already been registered with 'greater' for (<class 'numpy.dtypes.Float64DType'>, <class 'numpy.dtypes.Float64DType'>, <class 'numpy.dtypes.BoolDType'>)
  
  ../venv-test-arm64/lib/python3.13/site-packages/pywt/_functions.py:156: TypeError
  =========================== short test summary info ============================
  FAILED tests/test_concurrent.py::test_concurrent_cwt - TypeError: A loop/promoter has already been registered with 'greater' for (<class 'numpy.dtypes.Float64DType'>, <class 'numpy.dtypes.Float64DType'>, <class 'numpy.dtypes.BoolDType'>)
  ================ 1 failed, 812 passed, 225 deselected in 4.72s =================

That looks like a missing lock around a cache in NumPy, which is probably already fixed by one of @ngoldbaum's PRs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions