def exit(self): # Grab the lock. lock = koWndWrapper.create_mutex(self._commandmentsLockName) koWndWrapper.wait_for_single_object(lock) # Send __exit__ commandment. f = open(self._commandmentsFileName, 'a') f.write("__exit__\n") f.close() # Signal that there are new commandments: to ensure worker # thread doesn't wedge. newCommandments = koWndWrapper.create_event(self._commandmentsEventName) koWndWrapper.set_event(newCommandments) koWndWrapper.close_handle(newCommandments) # Release the lock. koWndWrapper.release_mutex(lock) koWndWrapper.close_handle(lock) self.join() try: os.remove(self._commandmentsFileName) except EnvironmentError: pass