objectProcessorThread.daemon=False# DON'T close the main program even the thread remains. This thread checks the shutdown variable after processing each object.
# DON'T close the main program even the thread remains.
# This thread checks the shutdown variable after processing
# each object.
objectProcessorThread.daemon=False
objectProcessorThread.start()
# Start the cleanerThread
singleCleanerThread=singleCleaner()
singleCleanerThread.daemon=True# close the main program even if there are threads left
# close the main program even if there are threads left
# Let us resend getpubkey objects if we have not yet heard a pubkey, and also msg objects if we have not yet heard an acknowledgement
# Let us resend getpubkey objects if we have not yet heard
# a pubkey, and also msg objects if we have not yet heard
# an acknowledgement
queryreturn=sqlQuery(
'''select toaddress, ackdata, status FROM sent WHERE ((status='awaitingpubkey' OR status='msgsent') AND folder='sent' AND sleeptill<? AND senttime>?) ''',
"SELECT toaddress, ackdata, status FROM sent"
" WHERE ((status='awaitingpubkey' OR status='msgsent')"
" AND folder='sent' AND sleeptill<? AND senttime>?)",
logger.error('Something went wrong in the singleCleaner thread: a query did not return the requested fields. '+repr(row))
logger.error(
'Something went wrong in the singleCleaner thread:'
' a query did not return the requested fields. %r',
row
)
self.stop.wait(3)
break
toAddress,ackData,status=row
@ -93,6 +117,7 @@ class singleCleaner(threading.Thread, StoppableThread):
# cleanup old nodes
now=int(time.time())
withknownnodes.knownNodesLock:
forstreaminknownnodes.knownNodes:
keys=knownnodes.knownNodes[stream].keys()
@ -109,18 +134,33 @@ class singleCleaner(threading.Thread, StoppableThread):
delknownnodes.knownNodes[stream][node]
continue
exceptTypeError:
print"Error in %s"%(str(node))
print"Error in %s"%node
keys=[]
# Let us write out the knowNodes to disk if there is anything new to write out.
# Let us write out the knowNodes to disk
# if there is anything new to write out.
ifshared.needToWriteKnownNodesToDisk:
try:
knownnodes.saveKnownNodes()
exceptExceptionaserr:
if"Errno 28"instr(err):
logger.fatal('(while receiveDataThread knownnodes.needToWriteKnownNodesToDisk) Alert: Your disk or data storage volume is full. ')
queues.UISignalQueue.put(('alert',(tr._translate("MainWindow","Disk full"),tr._translate("MainWindow",'Alert: Your disk or data storage volume is full. Bitmessage will now exit.'),True)))
@ -150,25 +192,38 @@ class singleCleaner(threading.Thread, StoppableThread):
defresendPubkeyRequest(address):
logger.debug('It has been a long time and we haven\'t heard a response to our getpubkey request. Sending again.')
logger.debug(
'It has been a long time and we haven\'t heard a response to our'
' getpubkey request. Sending again.'
)
try:
delstate.neededPubkeys[
address]# We need to take this entry out of the neededPubkeys structure because the queues.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.
# We need to take this entry out of the neededPubkeys structure
# because the queues.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.
delstate.neededPubkeys[address]
except:
pass
queues.UISignalQueue.put((
'updateStatusBar','Doing work necessary to again attempt to request a public key...'))
'updateStatusBar',
'Doing work necessary to again attempt to request a public key...'))
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE toaddress=?''',
address)
queues.workerQueue.put(('sendmessage',''))
defresendMsg(ackdata):
logger.debug('It has been a long time and we haven\'t heard an acknowledgement to our msg. Sending again.')
logger.debug(
'It has been a long time and we haven\'t heard an acknowledgement'
' to our msg. Sending again.'
)
sqlExecute(
'''UPDATE sent SET status='msgqueued' WHERE ackdata=?''',
ackdata)
queues.workerQueue.put(('sendmessage',''))
queues.UISignalQueue.put((
'updateStatusBar','Doing work necessary to again attempt to deliver a message...'))
'updateStatusBar',
'Doing work necessary to again attempt to deliver a message...'