def read_reply(self):
head = self.sock.recv(3)
if len(head) != 3:
- sys.stderr.write('Error: Short LAT packet\n')
- return None
+ raise LATClientException('Short LAT packet')
cmd = head[0]
length = ord(head[1])*256 + ord(head[2])
msg = self.sock.recv(length)
if cmd == LATCP_CMD_ERRORMSG:
- sys.stderr.write('Error: Received LAT error: %s\n'%msg)
+ raise LATClientException('Received LAT error: %s'%msg)
return (cmd, msg)
def get_fh(self):
USE_DB = 0
import ConfigParser
-import sys, os, string, re, pwd
+import sys, os, string, re, pwd, signal
+from traceback import print_tb
if USE_DB: import pg
from time import time, sleep
from popen2 import popen2
print
print "Connection died, trying again..."
-
if __name__ == '__main__':
+ def do_nothing(signum, stack): pass
+ def stop_server(signum, stack): raise KeyboardInterrupt
+ signal.signal(signal.SIGHUP, do_nothing)
+ signal.signal(signal.SIGTERM, stop_server)
+ signal.signal(signal.SIGINT, stop_server)
while True:
try:
do_vend_server()
except KeyboardInterrupt:
- print "Killed by SIGINT."
+ print "Killed by signal."
break
except:
(exc_type, exc_value, exc_traceback) = sys.exc_info()