From: Cameron Patrick Date: Sun, 1 Aug 2004 05:22:03 +0000 (+0000) Subject: can't readline from a socket X-Git-Tag: IMPORT-FROM-UCCCVS~103 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ddbc951719d0798a96355931cf5077b6de8d94aa;p=uccvend-vendserver.git can't readline from a socket --- diff --git a/sql-edition/servers/LATClient.py b/sql-edition/servers/LATClient.py index b7818de..2603ce9 100644 --- a/sql-edition/servers/LATClient.py +++ b/sql-edition/servers/LATClient.py @@ -46,9 +46,12 @@ class LATClient: if ord(cmd) == LATCP_CMD_ERRORMSG: raise LATClientException(msg) - r = select([self.sock], [], [], 2.0)[0] + self.rfh = self.sock.makefile('r') + self.wfh = self.sock.makefile('w') + + r = select([self.rfh], [], [], 2.0)[0] if r: - l = self.sock.readline() + l = self.rfh.readline() if l.find('Service in use') >= 0: print "Service in use, apparently: restarting DEC server" self.reboot_server() @@ -75,8 +78,11 @@ class LATClient: mop.write(self.priv_password+'\n') mop.write('init del 0\n') mop.close() + print print "Waiting 10 seconds for DEC server to come back to life..." sleep(10) + print "Rightyo, back to vending!" + print def read_reply(self): head = self.sock.recv(3) @@ -91,4 +97,4 @@ class LATClient: return (cmd, msg) def get_fh(self): - return (self.sock.makefile('r'), self.sock.makefile('w')) + return (self.rfh, self.wfh)