aws_metrics_custom_thread.py 723 B

1234567891011121314151617181920212223242526272829
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. from threading import Thread
  7. class AWSMetricsThread(Thread):
  8. """
  9. Custom thread for raising assertion errors on the main thread.
  10. """
  11. def __init__(self, **kwargs):
  12. super().__init__(**kwargs)
  13. self._error = None
  14. def run(self) -> None:
  15. try:
  16. super().run()
  17. except AssertionError as e:
  18. self._error = e
  19. def join(self, **kwargs) -> None:
  20. super().join(**kwargs)
  21. if self._error:
  22. raise AssertionError(self._error)