我有一个从数据库读取的路由,然后将传递给路由的值与数据库中的最新值进行比较
import multiprocessing
import time
class Generator(multiprocessing.Process):
def __init__(self):
self._vals = [] # keeps the internal state
self.vals = multiprocessing.Queue() # a queue for the exchange
super(Generator, self).__init__()
def run(self):
i = 0
while True:
time.sleep(1)
self._vals.append(i) # update the internal state
print('In Generator ', self._vals) # prints growing list
self.vals.put(self._vals) # add it to the queue
i += 1
class Starter():
def do_stuff(self):
gen = Generator()
gen.start()
while True:
print('In Starter ', gen.vals.get()) # print what's in the queue
time.sleep(1)
if __name__ == '__main__':
starter = Starter()
starter.do_stuff()
但是当将新行添加到块表时,块值永远不会改变。例如,当我第一次运行应用程序时,如果添加到表中的最后一个块的roundId是" 123",则上述路径中的block.roundId将是" 123"。但是,如果应用程序仍在运行并且数据库已更新,因此最新行的ID为" 456",则路径仍然会说block.roundId为" 123"。
在将新行添加到数据库并且它返回正确的值之后,我已经双重检查并使用了相同的查询,所以我认为问题是路由内部的问题。非常感谢任何帮助。
答案 0 :(得分:0)
我找到了答案!虽然我在保存数据的另一个文件中调用function convertObjectToList(obj) {
Object.keys(obj).map(function(key){
return [key, obj[key]]; //obj = [key, obj[key]];
});
}
,但是在读取路径内的数据之前我不得不再次调用它。谢谢PJ Santro!