catch_keyboard_interrupt_drawer_close.py 880 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. __author__ = "Christian Heider Nielsen"
  4. __doc__ = r"""
  5. Created on 07-02-2021
  6. """
  7. if __name__ == "__main__":
  8. import numpy
  9. import pytest
  10. from draugr.python_utilities import IgnoreInterruptSignal
  11. from draugr.drawers import DiscreteScrollPlot
  12. from draugr.stopping import CaptureEarlyStop
  13. stopped = False
  14. def stop() -> None:
  15. """
  16. :rtype: None
  17. """
  18. global stopped
  19. stopped = True
  20. @pytest.mark.skip
  21. def asidhsa() -> None:
  22. """
  23. :rtype: None
  24. """
  25. with DiscreteScrollPlot(num_bins=2) as rollout_drawer:
  26. with IgnoreInterruptSignal():
  27. with CaptureEarlyStop(stop, verbose=True):
  28. while not stopped:
  29. rollout_drawer.draw(numpy.random.randn(2))