pyramidscheme / pyramidtriangles

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

Create shutdown event for synchronization #28

Closed sul3n3t closed 5 years ago

sul3n3t commented 5 years ago

@johnemajor I believe this fixes the problem 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.

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.