Attempt to do a clean shutdown, but kill if it hangs
(self, timeout=10)
| 929 | wait_for(lambda: self.is_synced_with_bitcoin()) |
| 930 | |
| 931 | def stop(self, timeout=10): |
| 932 | """ Attempt to do a clean shutdown, but kill if it hangs |
| 933 | """ |
| 934 | |
| 935 | # Tell the daemon to stop |
| 936 | try: |
| 937 | # May fail if the process already died |
| 938 | self.rpc.stop() |
| 939 | except Exception: |
| 940 | pass |
| 941 | |
| 942 | self.rc = self.daemon.wait(timeout) |
| 943 | |
| 944 | # If it did not stop be more insistent |
| 945 | if self.rc is None: |
| 946 | self.rc = self.daemon.stop() |
| 947 | |
| 948 | self.daemon.cleanup() |
| 949 | |
| 950 | if self.rc != 0 and not self.may_fail: |
| 951 | raise ValueError("Node did not exit cleanly, rc={}".format(self.rc)) |
| 952 | else: |
| 953 | return self.rc |
| 954 | |
| 955 | def restart(self, timeout=10, clean=True): |
| 956 | """Stop and restart the lightning node. |