'Test that (lazy) compiling from several threads at once doesn\'t
produce errors (see issue #2403).'

def test_lock(self):

    errors = []
    @vectorize
    def foo(x):
        return (x + 1)
    def wrapper():
        try:
            a = np.ones((10,), dtype=np.float64)
            expected = (np.ones((10,), dtype=np.float64) + 1.0)
            np.testing.assert_array_equal(foo(a), expected)
        except BaseException as e:
            errors.append(e)
    threads = [threading.Thread(target=wrapper) for i in range(16)]
    for t in threads:
        t.start()
    for t in threads:
        t.join()
    self.assertFalse(errors)
