本文整理汇总了Python中twisted.internet.interfaces.IProcessTransport方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IProcessTransport方法的具体用法?Python interfaces.IProcessTransport怎么用?Python interfaces.IProcessTransport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.interfaces
的用法示例。
在下文中一共展示了interfaces.IProcessTransport方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: spawnProcess
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IProcessTransport [as 别名]
def spawnProcess(self, processProtocol, executable, args=(), env={},
path=None, uid=None, gid=None, usePTY=0, childFDs=None):
"""
@ivar processProtocol: Stores the protocol passed to the reactor.
@return: An L{IProcessTransport} provider.
"""
self.processProtocol = processProtocol
self.executable = executable
self.args = args
self.env = env
self.path = path
self.uid = uid
self.gid = gid
self.usePTY = usePTY
self.childFDs = childFDs
self.processTransport = MemoryProcessTransport()
self.processProtocol.makeConnection(self.processTransport)
return self.processTransport
示例2: test_cleanReactorKillsProcesses
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IProcessTransport [as 别名]
def test_cleanReactorKillsProcesses(self):
"""
The Janitor will kill processes during reactor cleanup.
"""
@implementer(IProcessTransport)
class StubProcessTransport(object):
"""
A stub L{IProcessTransport} provider which records signals.
@ivar signals: The signals passed to L{signalProcess}.
"""
def __init__(self):
self.signals = []
def signalProcess(self, signal):
"""
Append C{signal} to C{self.signals}.
"""
self.signals.append(signal)
pt = StubProcessTransport()
reactor = StubReactor([], [pt])
jan = _Janitor(None, None, reactor=reactor)
jan._cleanReactor()
self.assertEqual(pt.signals, ["KILL"])
示例3: test_cleanReactorKillsProcesses
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IProcessTransport [as 别名]
def test_cleanReactorKillsProcesses(self):
"""
The Janitor will kill processes during reactor cleanup.
"""
class StubProcessTransport(object):
"""
A stub L{IProcessTransport} provider which records signals.
@ivar signals: The signals passed to L{signalProcess}.
"""
implements(IProcessTransport)
def __init__(self):
self.signals = []
def signalProcess(self, signal):
"""
Append C{signal} to C{self.signals}.
"""
self.signals.append(signal)
pt = StubProcessTransport()
reactor = StubReactor([], [pt])
jan = _Janitor(None, None, reactor=reactor)
jan._cleanReactor()
self.assertEquals(pt.signals, ["KILL"])
示例4: makeConnection
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IProcessTransport [as 别名]
def makeConnection(self, process):
"""
Call L{IProtocol} provider's makeConnection method with an
L{ITransport} provider.
@param process: An L{IProcessTransport} provider.
"""
self.transport = _ProcessEndpointTransport(process)
return self.protocol.makeConnection(self.transport)
示例5: waitForOneProcess
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IProcessTransport [as 别名]
def waitForOneProcess(self, amount=10.0):
"""
Wait for an L{IProcessTransport} to be created by advancing the clock.
If none are created in the specified amount of time, raise an
AssertionError.
"""
self.advance(amount)
if self.processTransports:
return self.processTransports.pop(0)
else:
raise AssertionError(
"There were no process transports available. Calls: " +
repr(self.calls)
)