当前位置: 首页>>代码示例>>Python>>正文


Python Deferred.__init__方法代码示例

本文整理汇总了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()
开发者ID:HaeffnerLab,项目名称:sqip,代码行数:9,代码来源:test.py

示例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)
开发者ID:shylent,项目名称:texpect,代码行数:10,代码来源:mixin.py

示例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)
开发者ID:cordis,项目名称:spinoff,代码行数:11,代码来源:process.py

示例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)
开发者ID:fazme,项目名称:halirc,代码行数:12,代码来源:lib.py

示例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
开发者ID:GoodDingo,项目名称:fastjsonrpc,代码行数:12,代码来源:netstringclient.py

示例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
开发者ID:ComputerNetworks-UFRGS,项目名称:ManP2P-ng,代码行数:12,代码来源:message.py

示例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)
开发者ID:wrohdewald,项目名称:halirc,代码行数:14,代码来源:lib.py

示例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)
开发者ID:xony,项目名称:viff,代码行数:16,代码来源:runtime.py

示例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()
开发者ID:KDE,项目名称:kajongg,代码行数:18,代码来源:dialogs.py

示例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)
开发者ID:vesellov,项目名称:datahaven,代码行数:20,代码来源:transport_email.py

示例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)
开发者ID:EkkiD,项目名称:buildbotcustom,代码行数:22,代码来源:misc.py

示例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
开发者ID:rcarmo,项目名称:divmod.org,代码行数:38,代码来源:_unfortunate_defer_hack.py

示例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)
开发者ID:MaxFangX,项目名称:viff,代码行数:5,代码来源:util.py

示例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()
开发者ID:Architektor,项目名称:PySnip,代码行数:6,代码来源:crefutil.py

示例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
开发者ID:mineo,项目名称:lala,代码行数:5,代码来源:_helpers.py


注:本文中的twisted.internet.defer.Deferred.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。