catch_keyboard_interrupt_drawer_close.py 757 B

1234567891011121314151617181920212223242526272829303132
  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 import IgnoreInterruptSignal
  11. from draugr.drawers import DiscreteScrollPlot
  12. from draugr.stopping import CaptureEarlyStop
  13. stopped = False
  14. def stop():
  15. global stopped
  16. stopped = True
  17. @pytest.mark.skip
  18. def asidhsa():
  19. with DiscreteScrollPlot(num_bins=2) as rollout_drawer:
  20. with IgnoreInterruptSignal():
  21. with CaptureEarlyStop(stop, verbose=True):
  22. while not stopped:
  23. rollout_drawer.draw(numpy.random.randn(2))