'''The singleCleaner class is a timer-driven thread that cleans data structures to free memory, resends messages when a remote node doesn't respond, and sends pong messages to keep connections alive if the network isn't busy.
0,'pong','no data'))# commands the sendData threads to send out a pong message if they haven't sent anything else in the last five minutes. The socket timeout-time is 10 minutes.
# If we are running as a daemon then we are going to fill up the UI
# queue which will never be handled by a UI. We should clear it to
'''DELETE FROM pubkeys WHERE time<? AND usedpersonally='no'''')
shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit')
t=()
shared.sqlSubmitQueue.put(
'''select toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, pubkeyretrynumber, msgretrynumber FROM sent WHERE ((status='awaitingpubkey' OR status='msgsent') AND folder='sent') ''')# If the message's folder='trash' then we'll ignore it.
shared.sqlSubmitQueue.put(t)
queryreturn=shared.sqlReturnQueue.get()
forrowinqueryreturn:
iflen(row)<5:
shared.printLock.acquire()
sys.stderr.write(
'Something went wrong in the singleCleaner thread: a query did not return the requested fields. '+repr(row))
print'It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.'
try:
delneededPubkeys[
toripe]# We need to take this entry out of the neededPubkeys structure because the shared.workerQueue checks to see whether the entry is already present and will not do the POW and send the message because it assumes that it has already done it recently.
except:
pass
shared.UISignalQueue.put((
'updateStatusBar','Doing work necessary to again attempt to request a public key...'))
t=(int(
time.time()),pubkeyretrynumber+1,toripe)
shared.sqlSubmitQueue.put(
'''UPDATE sent SET lastactiontime=?, pubkeyretrynumber=?, status='msgqueued' WHERE toripe=?''')