Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unittests get stuck silently if there are non-daemon threads in the test #822

Closed
arcivanov opened this issue Oct 9, 2021 · 0 comments · Fixed by #823
Closed

Unittests get stuck silently if there are non-daemon threads in the test #822

arcivanov opened this issue Oct 9, 2021 · 0 comments · Fixed by #823

Comments

@arcivanov
Copy link
Member

[DEBUG/MainProcess] received (20, 1, 'startTest', 21, (<handler_tests.TestHandler object at 0x7fa0a01f12b0>,), {})
[DEBUG/MainProcess] calling 'startTest'.<xmlrunner.result._XMLTestResult run=21 errors=20 failures=0> (remote ID 1) with args=(<handler_tests.TestHandler object at 0x7fa0a01f12b0>,), kwargs={}
[DEBUG/MainProcess] sending (20, 24, '__str__', 21, (), {})
[DEBUG/unittest] received (20, 24, '__str__', 21, (), {})
[DEBUG/unittest] calling '__str__'.<handler_tests.TestHandler testMethod=test_unstructured_message> (remote ID 24) with args=(), kwargs={}
[DEBUG/unittest] sending (25, 'test_unstructured_message (handler_tests.TestHandler)')
[DEBUG/MainProcess] received (25, 'test_unstructured_message (handler_tests.TestHandler)')
[DEBUG/MainProcess] sending (20, 24, '__str__', 21, (), {})
[DEBUG/unittest] received (20, 24, '__str__', 21, (), {})
[DEBUG/unittest] calling '__str__'.<handler_tests.TestHandler testMethod=test_unstructured_message> (remote ID 24) with args=(), kwargs={}
[DEBUG/unittest] sending (25, 'test_unstructured_message (handler_tests.TestHandler)')
[DEBUG/MainProcess] received (25, 'test_unstructured_message (handler_tests.TestHandler)')
[DEBUG] starting test_unstructured_message (handler_tests.TestHandler)
[DEBUG/MainProcess] sending (20, 24, '_testMethodName', 22)
[DEBUG/unittest] received (20, 24, '_testMethodName', 22)
[DEBUG/unittest] sending (25, 'test_unstructured_message')
[DEBUG/MainProcess] received (25, 'test_unstructured_message')
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, 'addError', 21, (<handler_tests.TestHandler testMethod=test_unstructured_message>, (<class 'AttributeError'>, AttributeError("module 'fluent.sender' has no attribute 'FluentSender'"), <traceback object at 0x7fdaaf8d1b40>)), {})
[DEBUG/MainProcess] received (20, 1, 'addError', 21, (<handler_tests.TestHandler object at 0x7fa0a01f12b0>, (<class 'AttributeError'>, AttributeError("module 'fluent.sender' has no attribute 'FluentSender'"), <traceback object at 0x7fa0a1a50e80>)), {})
[DEBUG/MainProcess] calling 'addError'.<xmlrunner.result._XMLTestResult run=22 errors=20 failures=0> (remote ID 1) with args=(<handler_tests.TestHandler object at 0x7fa0a01f12b0>, (<class 'AttributeError'>, AttributeError("module 'fluent.sender' has no attribute 'FluentSender'"), <traceback object at 0x7fa0a1a50e80>)), kwargs={}
[DEBUG/MainProcess] sending (20, 24, 'shortDescription', 21, (), {})
[DEBUG/unittest] received (20, 24, 'shortDescription', 21, (), {})
[DEBUG/unittest] calling 'shortDescription'.<handler_tests.TestHandler testMethod=test_unstructured_message> (remote ID 24) with args=(), kwargs={}
[DEBUG/unittest] sending (25, None)
[DEBUG/MainProcess] received (25, None)
[DEBUG/MainProcess] sending (20, 24, '__str__', 21, (), {})
[DEBUG/unittest] received (20, 24, '__str__', 21, (), {})
[DEBUG/unittest] calling '__str__'.<handler_tests.TestHandler testMethod=test_unstructured_message> (remote ID 24) with args=(), kwargs={}
[DEBUG/unittest] sending (25, 'test_unstructured_message (handler_tests.TestHandler)')
[DEBUG/MainProcess] received (25, 'test_unstructured_message (handler_tests.TestHandler)')
[DEBUG/MainProcess] sending (20, 24, 'failureException', 22)
[DEBUG/unittest] received (20, 24, 'failureException', 22)
[DEBUG/unittest] sending (25, <class 'AssertionError'>)
[DEBUG/MainProcess] received (25, <class 'AssertionError'>)
[DEBUG/MainProcess] sending (20, 24, 'id', 21, (), {})
[DEBUG/unittest] received (20, 24, 'id', 21, (), {})
[DEBUG/unittest] calling 'id'.<handler_tests.TestHandler testMethod=test_unstructured_message> (remote ID 24) with args=(), kwargs={}
[DEBUG/unittest] sending (25, 'handler_tests.TestHandler.test_unstructured_message')
[DEBUG/MainProcess] received (25, 'handler_tests.TestHandler.test_unstructured_message')
[DEBUG/MainProcess] sending (20, 24, 'failureException', 22)
[DEBUG/unittest] received (20, 24, 'failureException', 22)
[DEBUG/unittest] sending (25, <class 'AssertionError'>)
[DEBUG/MainProcess] received (25, <class 'AssertionError'>)
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, 'stopTest', 21, (<handler_tests.TestHandler testMethod=test_unstructured_message>,), {})
[DEBUG/MainProcess] received (20, 1, 'stopTest', 21, (<handler_tests.TestHandler object at 0x7fa0a01f12b0>,), {})
[DEBUG/MainProcess] calling 'stopTest'.<xmlrunner.result._XMLTestResult run=22 errors=21 failures=0> (remote ID 1) with args=(<handler_tests.TestHandler object at 0x7fa0a01f12b0>,), kwargs={}
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, 'shouldStop', 22)
[DEBUG/MainProcess] received (20, 1, 'shouldStop', 22)
[DEBUG/MainProcess] sending (25, False)
[DEBUG/unittest] received (25, False)
[DEBUG/unittest] sending (20, 1, '_testRunEntered', 22)
[DEBUG/MainProcess] received (20, 1, '_testRunEntered', 22)
[DEBUG/MainProcess] sending (25, True)
[DEBUG/unittest] received (25, True)
[DEBUG/unittest] sending (20, 1, '_previousTestClass', 22)
[DEBUG/MainProcess] received (20, 1, '_previousTestClass', 22)
[DEBUG/MainProcess] sending (25, <class 'handler_tests.TestHandler'>)
[DEBUG/unittest] received (25, <class 'handler_tests.TestHandler'>)
[DEBUG/unittest] sending (20, 1, '_moduleSetUpFailed', 22)
[DEBUG/MainProcess] received (20, 1, '_moduleSetUpFailed', 22)
[DEBUG/MainProcess] sending (25, False)
[DEBUG/unittest] received (25, False)
[DEBUG/unittest] sending (20, 1, '_setupStdout', 21, (), {})
[DEBUG/MainProcess] received (20, 1, '_setupStdout', 21, (), {})
[DEBUG/MainProcess] calling '_setupStdout'.<xmlrunner.result._XMLTestResult run=22 errors=21 failures=0> (remote ID 1) with args=(), kwargs={}
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, '_restoreStdout', 21, (), {})
[DEBUG/MainProcess] received (20, 1, '_restoreStdout', 21, (), {})
[DEBUG/MainProcess] calling '_restoreStdout'.<xmlrunner.result._XMLTestResult run=22 errors=21 failures=0> (remote ID 1) with args=(), kwargs={}
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, '_previousTestClass', 22)
[DEBUG/MainProcess] received (20, 1, '_previousTestClass', 22)
[DEBUG/MainProcess] sending (25, <class 'handler_tests.TestHandler'>)
[DEBUG/unittest] received (25, <class 'handler_tests.TestHandler'>)
[DEBUG/unittest] sending (20, 1, '_moduleSetUpFailed', 22)
[DEBUG/MainProcess] received (20, 1, '_moduleSetUpFailed', 22)
[DEBUG/MainProcess] sending (25, False)
[DEBUG/unittest] received (25, False)
[DEBUG/unittest] sending (20, 1, '_setupStdout', 21, (), {})
[DEBUG/MainProcess] received (20, 1, '_setupStdout', 21, (), {})
[DEBUG/MainProcess] calling '_setupStdout'.<xmlrunner.result._XMLTestResult run=22 errors=21 failures=0> (remote ID 1) with args=(), kwargs={}
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, '_restoreStdout', 21, (), {})
[DEBUG/MainProcess] received (20, 1, '_restoreStdout', 21, (), {})
[DEBUG/MainProcess] calling '_restoreStdout'.<xmlrunner.result._XMLTestResult run=22 errors=21 failures=0> (remote ID 1) with args=(), kwargs={}
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (20, 1, '_testRunEntered', 23, False)
[DEBUG/MainProcess] received (20, 1, '_testRunEntered', 23, False)
[DEBUG/MainProcess] sending (25, None)
[DEBUG/unittest] received (25, None)
[DEBUG/unittest] sending (25, <xmlrunner.result._XMLTestResult object at 0x7fdaafd7e6d0>)
[DEBUG/MainProcess] received (25, <xmlrunner.result._XMLTestResult run=22 errors=21 failures=0>)
[DEBUG/MainProcess] sending (0, None)
[DEBUG/unittest] received (0, None)
[DEBUG/unittest] sending (1, None)
[DEBUG/MainProcess] received (1, None)
[INFO/unittest] process shutting down
[DEBUG/unittest] running all "atexit" finalizers with priority >= 0
[DEBUG/unittest] running the remaining "atexit" finalizers
^CTraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/spawn.py", line 129, in _main
    return self._bootstrap(parent_sentinel)
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/process.py", line 333, in _bootstrap
    threading._shutdown()
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/threading.py", line 1448, in _shutdown
    lock.acquire()
KeyboardInterrupt
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/logging/__init__.py", line 2142, in shutdown
Traceback (most recent call last):
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/plugins/python/unittest_plugin.py", line 153, in execute_tests_matching
    proc.join()
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/remote/__init__.py", line 149, in join
    return self.proc.join(timeout)
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/process.py", line 149, in join
    res = self._popen.wait(timeout)
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/popen_fork.py", line 43, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/popen_fork.py", line 27, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/cli.py", line 475, in main
    summary = reactor.build(
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/reactor.py", line 235, in build
    execution_summary = self.build_execution_plan(tasks, execution_plan)
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/reactor.py", line 270, in build_execution_plan
    task_execution_summaries = self.execution_manager.execute_execution_plan(
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/execution.py", line 393, in execute_execution_plan
    summaries.append(self.execute_task(task, **kwargs))
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/execution.py", line 340, in execute_task
    task.execute(self.logger, kwargs, _executable=_executable)
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/execution.py", line 179, in execute
    executable.execute(argument_dict)
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/execution.py", line 95, in execute
    self.callable(*arguments)
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/plugins/python/unittest_plugin.py", line 65, in run_unit_tests
    run_tests(project, logger, reactor, "unittest", "unit tests")
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/plugins/python/unittest_plugin.py", line 90, in run_tests
    result, console_out = execute_tests_matching(
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/plugins/python/unittest_plugin.py", line 156, in execute_tests_matching
    proc.close()
  File "/home/arcivanov/.pyenv/versions/3.9.7/envs/fluent-logger-3.9.7/lib/python3.9/site-packages/pybuilder/remote/__init__.py", line 155, in close
    return self.proc.close()
  File "/home/arcivanov/.pyenv/versions/3.9.7/lib/python3.9/multiprocessing/process.py", line 181, in close
    raise ValueError("Cannot close a process while it is still running. "
ValueError: Cannot close a process while it is still running. You should first call join() or terminate().
------------------------------------------------------------
BUILD FAILED - ValueError: Cannot close a process while it is still running. You should first call join() or terminate(). (multiprocessing/process.py:181)
------------------------------------------------------------
Build finished at 2021-10-09 18:33:15
Build took 28 seconds (28592 ms)
    h.close()
  File "/home/arcivanov/Documents/src/arcivanov/fluent-logger/src/main/python/fluent/handler.py", line 244, in close
    self.sender.close()
  File "/home/arcivanov/Documents/src/arcivanov/fluent-logger/src/main/python/fluent/handler.py", line 207, in sender
    self._sender = self.getSenderInstance(
  File "/home/arcivanov/Documents/src/arcivanov/fluent-logger/src/main/python/fluent/handler.py", line 223, in getSenderInstance
    sender_class = self.getSenderClass()
  File "/home/arcivanov/Documents/src/arcivanov/fluent-logger/src/main/python/fluent/handler.py", line 202, in getSenderClass
    return sender.FluentSender
AttributeError: module 'fluent.sender' has no attribute 'FluentSender'
@arcivanov arcivanov changed the title Unittests get stuck possibly if there is an error in atexit finalizer Unittests get stuck silently if there are non-daemon threads in the test Oct 10, 2021
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 10, 2021
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 10, 2021
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 10, 2021
arcivanov added a commit to arcivanov/pybuilder that referenced this issue Oct 10, 2021
Also add tracing option to trace remote tests
Add integration tests to cover

fixes pybuilder#822
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant