多处理初始化类中的函数

时间:2015-11-14 20:08:01

标签: python class python-multiprocessing

我正在尝试使用多处理来初始化类中的函数,方法是从函数调用它,该函数位于同一个类中

StringBuilder sb2 = new StringBuilder();
for (int i = 0; i < mdbytes.length; i++) {
    sb2.append(String.format("%02x", 0xFF & mdbytes[i]));
}
System.out.println("Hex format: " + sb2.toString());

但是当我调用流时会引发错误

def Streaminit(self,_track): self.twitterStream = tweepy.Stream(self.auth, Twitterapi.Listener()) self.twitterStream.filter(track=_track) def Stream(self,track=""): self.streamobj = multiprocessing.Process(target = self.Streaminit(),args=(track,))

我在这个

中做错了什么

1 个答案:

答案 0 :(得分:0)

  //Check if all wires are connected
if (digitalRead(wire_BROWN) == LOW){
 if (digitalRead(wire_ORANGE) == LOW){
   if (digitalRead(wire_RED) == LOW){
    if (digitalRead(wire_GREEN) == LOW){
      if (digitalRead(wire_BLUE) == LOW){
        if (digitalRead(wire_PURPLE) == LOW){
          if (digitalRead(wire_GREY) == LOW){
            if (digitalRead(wire_WHITE) == LOW){
              if (digitalRead(wire_BLACK) == LOW){
                lcd.print(pass);
                delay(3000);
                lcd.clear();
                lcd.print("Status: ARMED");
                testPassed = true;
              } else lcd.print(fail);
            } else lcd.print(fail);
          } else lcd.print(fail);
        } else lcd.print(fail);
      } else lcd.print(fail);
    } else lcd.print(fail);
  } else lcd.print(fail);
 } else lcd.print(fail);
} else lcd.print(fail);

你在这里没有参数调用self.streamobj = multiprocessing.Process(target = self.Streaminit(),args=(track,)) 函数,它需要一个参数(加Streaminit)。所以很自然它会导致错误。

您想要做的是将函数本身传递给self

multiprocessing.Process