本文整理汇总了Python中twisted.internet.defer.Deferred.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Deferred.__init__方法的具体用法?Python Deferred.__init__怎么用?Python Deferred.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.defer.Deferred
的用法示例。
在下文中一共展示了Deferred.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, pipe, width=5):
Deferred.__init__(self)
self.pipe = pipe
self.width = width
self.waiting = None
self.running = 0
self.results = DeferredQueue()
示例2: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, timeout=None):
r"""
@param timeout: Timeout object.
@type timeout: Any object, providing L{IDelayedCall<twisted.internet.interfaces.IDelayedCall>}
"""
self._timeout = timeout
Deferred.__init__(self)
示例3: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, executable, args=[], env=None, termination_signal='KILL', path=None):
assert termination_signal in ALLOWED_TERMINATION_SIGNALS
Deferred.__init__(self, canceller=lambda _: self._kill())
self._termination_signal = termination_signal
self._stdout_output = []
self._stderr_output = []
self._killed = False
reactor.spawnProcess(self, executable, args=[os.path.basename(executable)] + args, env=env, path=path)
示例4: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, protocol, message, timeout=5):
"""data without line eol. timeout -1 means we do not expect an answer."""
self.protocol = protocol
self.createTime = datetime.datetime.now()
self.sendTime = None
assert isinstance(message, Message), message
self.message = message
self.timeout = timeout
self.retries = 0
Deferred.__init__(self)
示例5: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, verbose=False):
"""
Remember verbosity level for potential logging.
@type verbose: bool
@param verbose: If True, we log the response JSON
"""
Deferred.__init__(self)
self.verbose = verbose
示例6: reset
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def reset(self, canceller=None):
cback = self.callbacks
canceller = (canceller if canceller is not None
else self._canceller if self._canceller != None
else None)
Deferred.__init__(self, canceller)
self.callbacks = cback
示例7: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, protocol, message, maxWaitSeconds=None):
"""data without line eol. maxWaitSeconds -1 means we do not expect an answer."""
if maxWaitSeconds is None:
maxWaitSeconds = 5
self.protocol = protocol
self.message = message
self.maxWaitSeconds = maxWaitSeconds
self.createTime = datetime.datetime.now()
self.sendTime = None
self.answerTime = datetime.datetime.now() if maxWaitSeconds == -1 else None
assert isinstance(message, Message), message
Deferred.__init__(self)
示例8: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, runtime, field, value=None):
"""Initialize a share.
If an initial value is given, it will be passed to
:meth:`callback` right away.
"""
assert field is not None, "Cannot construct share without a field."
assert callable(field), "The field is not callable, wrong argument?"
Deferred.__init__(self)
self.runtime = runtime
self.field = field
if value is not None:
self.callback(value)
示例9: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, dlg, modal=True, always=False):
Deferred.__init__(self)
self.dlg = dlg
self.modal = modal
self.always = always
if Options.gui:
if hasattr(self.dlg, 'buttonClicked'):
self.dlg.buttonClicked.connect(self.clicked)
else:
self.dlg.accepted.connect(self.clicked)
self.dlg.rejected.connect(self.cancel)
if Internal.reactor:
Internal.reactor.callLater(0, self.__execute)
else:
# we do not yet have a reactor in initDb()
self.__execute()
示例10: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, server, port, login, password,
ssl_flag, timeout=5,
receive_event=None, no_messages_event=None):
Deferred.__init__(self)
dhnio.Dprint(16, 'transport_email.PopCheckerServer.__init__')
self.server = server
try:
self.port = int(port)
except:
self.port = 110
self.ssl_flag = ssl_flag
self.addCallbacks(self.stop,self.fail)
self.loopcall = None
self.shutdown = False
self.checker = PopChecker(login, password,
timeout, self.run, receive_event,
finish_event=self.finish_callback,
no_messages_event=no_messages_event)
示例11: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, wrapped_d):
Deferred.__init__(self)
self.already_fired = False
def callback(*args, **kwargs):
if not self.already_fired:
self.already_fired = True
self.callback(*args, **kwargs)
else:
log.msg("callback called again: %s %s" % (args, kwargs))
def errback(*args, **kwargs):
if not self.already_fired:
self.already_fired = True
self.errback(*args, **kwargs)
else:
log.msg("errback called again: %s %s" % (args, kwargs))
wrapped_d.addCallbacks(callback, errback)
示例12: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, deferredList, fireOnOneCallback=0, fireOnOneErrback=0,
consumeErrors=0):
"""Initialize a DeferredList.
@type deferredList: C{list} of L{Deferred}s
@param deferredList: The list of deferreds to track.
@param fireOnOneCallback: (keyword param) a flag indicating that
only one callback needs to be fired for me to call
my callback
@param fireOnOneErrback: (keyword param) a flag indicating that
only one errback needs to be fired for me to call
my errback
@param consumeErrors: (keyword param) a flag indicating that any errors
raised in the original deferreds should be
consumed by this DeferredList. This is useful to
prevent spurious warnings being logged.
"""
self.resultList = [None] * len(deferredList)
Deferred.__init__(self)
if len(deferredList) == 0 and not fireOnOneCallback:
self.callback(self.resultList)
# These flags need to be set *before* attaching callbacks to the
# deferreds, because the callbacks use these flags, and will run
# synchronously if any of the deferreds are already fired.
self.fireOnOneCallback = fireOnOneCallback
self.fireOnOneErrback = fireOnOneErrback
self.consumeErrors = consumeErrors
self.finishedCount = 0
index = 0
for deferred in deferredList:
deferred.addCallbacks(self._cbDeferred, self._cbDeferred,
callbackArgs=(index,SUCCESS),
errbackArgs=(index,FAILURE))
index = index + 1
示例13: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, result):
Deferred.__init__(self)
self._wait(result)
示例14: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self):
Deferred.__init__(self)
NotKnown.__init__(self)
self.pause()
示例15: __init__
# 需要导入模块: from twisted.internet.defer import Deferred [as 别名]
# 或者: from twisted.internet.defer.Deferred import __init__ [as 别名]
def __init__(self, data=None):
Deferred.__init__(self)
self.data = data