Created
October 20, 2020 21:51
-
-
Save belovachap/6026afb78e08988eaddc6d61b41dd1b2 to your computer and use it in GitHub Desktop.
Python script to restart a crashing xpm mining client on Windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import pexpect | |
import pexpect.popen_spawn | |
def open_xpm_client(): | |
print('Opening xpm_client...') | |
xpm_client = pexpect.popen_spawn.PopenSpawn('xpmclient.exe') | |
print('xpm_client open!') | |
return xpm_client | |
def close_xpm_client(xpm_client): | |
print('Closing xpm_client...') | |
xpm_client.kill(signal.SIGTERM) | |
xpm_client.wait() | |
print("xmp_client closed!") | |
try: | |
xpm_client = open_xpm_client() | |
while True: | |
try: | |
xpm_client.expect('crashed!', timeout=1) | |
print('Crash detected!') | |
close_xpm_client(xpm_client) | |
xpm_client = open_xpm_client() | |
except pexpect.TIMEOUT: | |
continue | |
except KeyboardInterrupt: | |
print('KeyboardInterrupt detected!') | |
finally: | |
close_xpm_client(xpm_client) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment