mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
copy in changes from dev branch
This commit is contained in:
parent
fc4e577f1b
commit
ddadee9bef
1 changed files with 9 additions and 4 deletions
|
@ -171,13 +171,13 @@ def query(req, params):
|
||||||
print('params', params)
|
print('params', params)
|
||||||
params = json.loads(params)
|
params = json.loads(params)
|
||||||
ids = params['ids']
|
ids = params['ids']
|
||||||
timeoutSecs = 'timeoutSecs' in params and float(params['timeoutSecs']) or 2.0
|
# timeoutSecs = 'timeoutSecs' in params and float(params['timeoutSecs']) or 2.0
|
||||||
|
|
||||||
idsLen = 0
|
idsLen = 0
|
||||||
for id in ids: idsLen += len(id)
|
for id in ids: idsLen += len(id)
|
||||||
|
|
||||||
tcpSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
tcpSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
tcpSock.settimeout(timeoutSecs)
|
# tcpSock.settimeout(timeoutSecs)
|
||||||
tcpSock.connect(('127.0.0.1', 10998))
|
tcpSock.connect(('127.0.0.1', 10998))
|
||||||
|
|
||||||
lenShort = 2 + idsLen + len(ids) + 2
|
lenShort = 2 + idsLen + len(ids) + 2
|
||||||
|
@ -188,8 +188,9 @@ def query(req, params):
|
||||||
|
|
||||||
for id in ids: tcpSock.send(id + '\n')
|
for id in ids: tcpSock.send(id + '\n')
|
||||||
|
|
||||||
msgsLists = {}
|
result = {'ids':ids}
|
||||||
try:
|
try:
|
||||||
|
msgsLists = {}
|
||||||
shortUnpacker = struct.Struct('!H')
|
shortUnpacker = struct.Struct('!H')
|
||||||
resLen, = shortUnpacker.unpack(tcpSock.recv(shortUnpacker.size)) # not getting all bytes
|
resLen, = shortUnpacker.unpack(tcpSock.recv(shortUnpacker.size)) # not getting all bytes
|
||||||
nameCount, = shortUnpacker.unpack(tcpSock.recv(shortUnpacker.size))
|
nameCount, = shortUnpacker.unpack(tcpSock.recv(shortUnpacker.size))
|
||||||
|
@ -212,10 +213,14 @@ def query(req, params):
|
||||||
msgs.append(msg)
|
msgs.append(msg)
|
||||||
perGame.append(msgs)
|
perGame.append(msgs)
|
||||||
msgsLists[ids[ii]] = perGame
|
msgsLists[ids[ii]] = perGame
|
||||||
|
|
||||||
|
result['msgs'] = msgsLists
|
||||||
except:
|
except:
|
||||||
|
# Anything but a timeout should mean we abort/send nothing
|
||||||
|
result['err'] = 'hit exception'
|
||||||
None
|
None
|
||||||
|
|
||||||
return json.dumps(msgsLists)
|
return json.dumps(result)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
result = None
|
result = None
|
||||||
|
|
Loading…
Add table
Reference in a new issue