Skip to content

Flakey threaded tests #1041

@benjeffery

Description

@benjeffery

[gw0] [ 51%] FAILED tests/test_threads.py::TestTables::test_simplify_access_mutations

=================================== FAILURES ===================================
__________________ TestTables.test_simplify_access_mutations ___________________
[gw0] darwin -- Python 3.6.11 /usr/local/miniconda/envs/anaconda-client-env/bin/python3.6

self = <tests.test_threads.TestTables object at 0x7f8b65e76b00>

    def test_simplify_access_mutations(self):
>       self.run_simplify_access_table("mutations", "site")

tests/test_threads.py:265: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_threads.py:238: in run_simplify_access_table
    self.run_failing_reader(writer, reader)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.test_threads.TestTables object at 0x7f8b65e76b00>
writer = <function TestTables.run_simplify_access_table.<locals>.writer at 0x7f8b63a4bd90>
reader = <function TestTables.run_simplify_access_table.<locals>.reader at 0x7f8b63a4bd08>
num_readers = 32

    def run_failing_reader(self, writer, reader, num_readers=32):
        """
        Runs a test in which a single writer acceses some tables
        and a bunch of other threads try to read the data.
        """
        barrier = threading.Barrier(num_readers + 1)
    
        def writer_proxy():
            barrier.wait()
            writer()
    
        def reader_proxy(thread_index, results):
            barrier.wait()
            # Attempts to operate on a table while locked should raise a RuntimeError
            try:
                reader(thread_index, results)
                results[thread_index] = 0
            except RuntimeError:
                results[thread_index] = 1
    
        writer_thread = threading.Thread(target=writer_proxy)
        writer_thread.start()
        results = run_threads(reader_proxy, num_readers)
        writer_thread.join()
    
>       failures = sum(results)
E       TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

tests/test_threads.py:202: TypeError
----------------------------- Captured stderr call -----------------------------
Exception in thread Thread-296:
Traceback (most recent call last):
  File "/usr/local/miniconda/envs/anaconda-client-env/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/miniconda/envs/anaconda-client-env/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/runner/work/tskit/tskit/python/tests/test_threads.py", line 192, in reader_proxy
    reader(thread_index, results)
  File "/Users/runner/work/tskit/tskit/python/tests/test_threads.py", line 236, in reader
    assert x.shape[0] == len(table)
AssertionError: assert 152 == 38
  +152
  -38

=============================== warnings summary ===============================

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions