그래서 사람들이 자동으로 업데이트하는 프로그램을 만들었습니다. 모든 작업을 마치고 돌아가서 멀티 스레드로 만들었습니다. 스레드가 하드 코드 할 때 모든 것이 작동합니다. 내 스스로, 지금은 파일에서 모든 사용자가 읽을 수있는 새로운 스레드를 만들고 싶어, 나는 내 프로그램에 이것을 어떻게 해야할지 모르겠다. 나머지 프로그램은 스레드를 동적으로 만들 필요가 있습니다. 내 코드는 아래에있다, 나는 스레드가 시작되어야한다고 생각하는 곳에 주석을 달았다.동적으로 스레드를 만들어서 각 사용자가 파이썬에서 텍스트 파일을 읽음
def run(self)
try:
location = "location"
onloc = "onloc"
port = 22
self.Put(location, onloc, self.ThreadIP, self.ThreadPw, self.ThreadUser, port)
re = self.HTTPing("https://%s" %self.ThreadIP)
while not re:
time.sleep(60)
self.HTTPing("https://%s" %self.ThreadIP)
print "Is on"
except:
print ("This ip does not est %s" %self.ThreadIP)
with open("People.txt" , 'r') as inFile:
for line in inFile:
ip,user,password = line.strip().split(',')
""what should i put here to make threads
'MyThreadClass (arguments, go, here) .start()'? – Kevin
적절한 인수를 전달하여 스레드 클래스의 인스턴스를 만들어야합니다. 이러한 인스턴스를 일종의 데이터 구조 안에 저장할 수도 있습니다. – tijko