2
setup.inQ
은 complete.inQ
과 다른가요?파이썬 : 공장 속성
하나의 큐에 뭔가를 넣으면 다른 큐에 나타나지 않을 것입니다. 맞습니까?
import Queue
class Factory:
name = ""
inQ = Queue.Queue()
outQ = Queue.Queue()
def worker(self): pass
@staticmethod
def getFactory(factory_name):
if factory_name == "setup":
return SetupFactory()
elif factory_name == "dispatch":
return DispatchFactory()
elif factory_name == "complete":
return CompleteFactory()
else:
return None
class SetupFactory(Factory):
name = "setup"
def worker(self):
#extend
class DispatchFactory(Factory):
name = "dispatch"
def worker(self):
#extend
class CompleteFactory(Factory):
name = "complete"
def worker(self):
#extend
setup = Factory.getFactory("setup")
complete = Factory.getFactory("complete")
아 감사합니다. 그래서 내가 Queue.Queue() 모든 클래스에 표시 할 항목을하지 않을 경우 모든 큐에 표시 할 수 있습니다. – ealeon
@ealeon - 아마도 당신이 그 코드를'__init__'로 옮기고 싶다고 생각합니다. – mgilson
ohhh yeah illh 그것을 시도하십시오! – ealeon