pyramidscheme / pyramidtriangles

Software to run the Pyramid Scheme triangles
3 stars 0 forks source link

Create shutdown event for synchronization, sACN model shutdown #29

Closed sul3n3t closed 5 years ago

sul3n3t commented 5 years ago

@johnemajor I believe this fixes the problem (#28) you were having with cherrypy Autoreload failing.

This PR adds a threading.Event to coordinate shutdown. Similar to a queue, it is built to be thread-safe. It allows cherrypy to signal shutdown when it's Autoreload detects file changes. The problem was with OSC threads hanging around. In this PR a thread is created to launch OSC, wait for the shutdown event, then cleanup the OSC threads. For sACN, the model is passed to TriangleServer so it can be closed as well.

I think this removes the need for the restart_server() method, but please correct me if I've misunderstood.

Also, the ShowRunner main loop is more responsive. Previously, time.sleep(delay) would prevent a shutdown until possibly delay seconds pass. In this PR, that can be interrupted and shutdown immediately.

Brightness scale was moved to the model for applying it and show runner for managing state. It doesn't have to be kept track of or passed in so many places.