MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / run

Method run

src/class_objectProcessor.py:55–95  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

53
54
55 def run(self):
56 while True:
57 objectType, data = queues.objectProcessorQueue.get()
58
59 self.checkackdata(data)
60
61 try:
62 if objectType == 0: # getpubkey
63 self.processgetpubkey(data)
64 elif objectType == 1: #pubkey
65 self.processpubkey(data)
66 elif objectType == 2: #msg
67 self.processmsg(data)
68 elif objectType == 3: #broadcast
69 self.processbroadcast(data)
70 elif objectType == 'checkShutdownVariable': # is more of a command, not an object type. Is used to get this thread past the queue.get() so that it will check the shutdown variable.
71 pass
72 else:
73 if isinstance(objectType, int):
74 logger.info('Don\'t know how to handle object type 0x%08X', objectType)
75 else:
76 logger.info('Don\'t know how to handle object type %s', objectType)
77 except helper_msgcoding.DecompressionSizeException as e:
78 logger.error("The object is too big after decompression (stopped decompressing at %ib, your configured limit %ib). Ignoring", e.size, BMConfigParser().safeGetInt("zlib", "maxsize"))
79 except varintDecodeError as e:
80 logger.debug("There was a problem with a varint while processing an object. Some details: %s" % e)
81 except Exception as e:
82 logger.critical("Critical error within objectProcessorThread: \n%s" % traceback.format_exc())
83
84 if state.shutdown:
85 time.sleep(.5) # Wait just a moment for most of the connections to close
86 numberOfObjectsThatWereInTheObjectProcessorQueue = 0
87 with SqlBulkExecute() as sql:
88 while queues.objectProcessorQueue.curSize > 0:
89 objectType, data = queues.objectProcessorQueue.get()
90 sql.execute('''INSERT INTO objectprocessorqueue VALUES (?,?)''',
91 objectType,data)
92 numberOfObjectsThatWereInTheObjectProcessorQueue += 1
93 logger.debug('Saved %s objects from the objectProcessorQueue to disk. objectProcessorThread exiting.' % str(numberOfObjectsThatWereInTheObjectProcessorQueue))
94 state.shutdown = 2
95 break
96
97 def checkackdata(self, data):
98 # Let's check whether this is a message acknowledgement bound for us.

Callers

nothing calls this directly

Calls 10

checkackdataMethod · 0.95
processgetpubkeyMethod · 0.95
processpubkeyMethod · 0.95
processmsgMethod · 0.95
processbroadcastMethod · 0.95
BMConfigParserClass · 0.90
SqlBulkExecuteClass · 0.85
safeGetIntMethod · 0.80
executeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected