本文整理汇总了Python中twisted.internet.defer.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _handle_event
def _handle_event(self, event_type, args=(), respond_to=False):
"""handles event dispatch"""
for event in self.events[event_type]:
if self.config['threaded']:
threads.deferToThread(self._event, event, args, respond_to)
else:
defer.execute(self._event, event, args, respond_to)
开发者ID:zeekay,项目名称:chii,代码行数:7,代码来源:chii.py
示例2: handle_line
def handle_line(self, line):
"""Deal with a line of input."""
# TODO this should be part of debug output in the irc shell, too, and
# not baked in here
log.msg("received: " + repr(line))
from twisted.internet import defer
# XXX this is here cause it allows exceptions to actually be caught; be more careful with that in general
defer.execute(self._handle_line, line)
开发者ID:Motoma,项目名称:dywypi,代码行数:8,代码来源:shell.py
示例3: _start_tasks
def _start_tasks(self):
"""starts all tasks"""
if self.tasks:
for task in self.tasks:
func, repeat, scale = self.tasks[task]
if self.config['threaded']:
threads.deferToThread(self._task, task, func, repeat, scale)
else:
defer.execute(self._task, task, func, repeat, scale)
开发者ID:zeekay,项目名称:chii,代码行数:9,代码来源:chii.py
示例4: _handle_command
def _handle_command(self, channel, nick, host, msg):
"""handles command dispatch"""
msg = msg.split()
command = self.commands.get(msg[0][1:].lower(), None)
if command:
if self._check_permission(command._restrict, nick, host):
if self.config['threaded']:
threads.deferToThread(self._command, command, channel, nick, host, msg)
else:
defer.execute(self._command, command, channel, nick, host, msg)
开发者ID:zeekay,项目名称:chii,代码行数:10,代码来源:chii.py
示例5: listen
def listen(self, protocolFactory):
"""
Implement L{IStreamServerEndpoint.listen} to listen on a TCP socket
"""
return defer.execute(
self._reactor.listenTCP, self._port, protocolFactory, backlog=self._backlog, interface=self._interface
)
开发者ID:pombredanne,项目名称:toppatch,代码行数:7,代码来源:endpoints.py
示例6: wrapper
def wrapper(*args, **kwargs):
assert len(kwargs) == 0, (
"The Provisioning API is meant to be used via XML-RPC, "
"for now, so its methods are prevented from use with "
"keyword arguments, which XML-RPC does not support.")
# TODO: Convert exceptions into Faults.
return defer.execute(func, *args)
开发者ID:deepakhajare,项目名称:maas,代码行数:7,代码来源:fakeapi.py
示例7: loadModel
def loadModel(self, path, request):
"""Load a model, for the given path and request.
@rtype: L{Deferred}
"""
from twisted.internet.defer import execute
return execute(self.loadModelNow, path, request)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:7,代码来源:tapestry.py
示例8: wrapper
def wrapper(*args, **kwargs):
if not _testing:
return deferToThreadPool(reactor, _threadpool,
run_in_tx, fun, *args, **kwargs)
else:
# No threading during testing
return defer.execute(run_in_tx, fun, *args, **kwargs)
开发者ID:bbc88ks,项目名称:opennode-management,代码行数:7,代码来源:db.py
示例9: listen
def listen(self, protocolFactory):
return defer.execute(twisted.listenTLS,
self._reactor,
self._port,
protocolFactory,
self._credentials,
backlog=self._backlog,
interface=self._interface)
开发者ID:bekomy,项目名称:xmppserver,代码行数:8,代码来源:tls.py
示例10: listen
def listen(self, protocolFactory):
"""
Implement L{IStreamServerEndpoint.listen} to listen on a UNIX socket.
"""
return defer.execute(self._reactor.listenUNIX, self._address,
protocolFactory,
backlog=self._backlog,
mode=self._mode,
wantPID=self._wantPID)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:endpoints.py
示例11: callRemote
def callRemote(self, method, *args, **kw):
if hasattr(self.interfaceClass, method):
result = defer.execute(self._callMethod, method, *args, **kw)
return result
elif self.failWhenNotImplemented:
return defer.fail(
Failure(NotImplementedError,
"No Such Method in Interface: %s" % method))
else:
return defer.succeed(None)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:10,代码来源:util.py
示例12: get_state
def get_state(self):
"""
Reads state from the file.
:returns: `Deferred` that fires with the current state.
"""
def _read():
if os.path.exists(self.filename):
return open(self.filename).read()
return defer.execute(_read)
开发者ID:MariaAbrahms,项目名称:otter,代码行数:11,代码来源:state.py
示例13: lookupAddress
def lookupAddress(self, name, timeout=None):
"""
The twisted function which is called when an A record lookup is
requested.
:param name: The domain name being queried for (e.g. example.org).
:param timeout: Time in seconds to wait for the query response.
(optional, default: None)
:return: A DNS response for the record query.
"""
log.msg("Query for %s" % name)
d = defer.execute(queryAddress, name)
return d
开发者ID:rail,项目名称:ec2-dns,代码行数:12,代码来源:ec2-dns.py
示例14: connectionMade
def connectionMade(self):
if not self.factory.retrieved_file_queue:
# Create once, queue persists in the factory
self.factory.retrieved_file_queue = collections.deque('', SEARCH_SIZE)
# Only need to scan the local directory during startup
if len(self.factory.retrieved_file_queue) == 0:
d = defer.execute(self._process_local_files)
d.addErrback(self._process_local_files_errback)
d.addCallback(lambda ignore: self._change_directory()) # suppress the returned result
else:
self._change_directory()
开发者ID:ronkyo,项目名称:ooi_port_agent,代码行数:13,代码来源:zplsc_agent.py
示例15: freeze_commit
def freeze_commit(self, events):
"""Unfreezes the frozen path, sending received events if not dirty.
If events for that path happened:
- return True
else:
- push the here received events, return False
"""
if self._processor.frozen_path is None:
raise ValueError("Committing with nothing frozen!")
d = defer.execute(self._processor.freeze_commit, events)
return d
开发者ID:magicicada-bot,项目名称:magicicada-client,代码行数:13,代码来源:fsevents_daemon.py
示例16: run
def run(self):
d = defer.execute(self.__callbacks[0], *self.__args)
if not self.__err_back:
self.__err_back = self.on_error
d.addErrback(self.__err_back)
for cb in self.__callbacks[1:]:
d.addCallback(cb)
self.__reactor.callLater(self.__interval, self.run)
if not self.__reactor.running:
self.__reactor.run()
开发者ID:adeelshahid,项目名称:zipnish,代码行数:14,代码来源:LogReader.py
示例17: execute_db_retriever
def execute_db_retriever(engine, database, **kwargs):
log.msg("Get db data is called with %s:%s" % (engine, database))
def callback():
headerRow = ["name", "city", "country"]
dataRows = [["Lionel", "Rosario", "Argentina"], ["Andres", "Albacete", "Spain"]]
stream = Stream()
stream.configs = dict(kwargs)
stream.configs["engine"] = engine
stream.configs["database"] = database
db = DatabaseRetriever(stream)
dataRows = db.execute()
result = {"headerRow": stream.configs["columns"], "dataRows": dataRows}
return result
return defer.execute(callback)
开发者ID:disterics,项目名称:leftronicd,代码行数:16,代码来源:dbretriever.py
示例18: setup_display
def setup_display(self, result=None):
def func0(result=None):
self.surface = pygame.display.set_mode(DISPLAY_SIZE)
self.surface.fill((0, 0, 0))
self.background = pygame.Surface(DISPLAY_SIZE)
self.background.fill((0, 0, 0))
def func1(result=None):
return threads.deferToThread(self.handle_display)
def func2(result=None):
c = task.LoopingCall(func1)
c.start(FPS, now=False)
d = defer.execute(func0)
d.addCallback(func2)
return d
开发者ID:bitcraft,项目名称:txPong,代码行数:17,代码来源:run_game.py
示例19: get_buddyicon
def get_buddyicon(flickr, data, size=48):
"""Lookup the buddyicon from the data in @data using @flickr and resize it
to @size pixels."""
global __buddy_cache
if __buddy_cache is None:
folder = os.path.join (get_cache_path(), "postr")
if not os.path.exists(folder):
os.makedirs(folder)
path = os.path.join (folder, "buddyicons")
try:
__buddy_cache = bsddb3.hashopen(path, "c")
except bsddb3.db.DBInvalidArgError:
# The database needs upgrading, so delete it
os.remove(path)
__buddy_cache = bsddb3.hashopen(path, "c")
def load_thumb(page, size):
loader = GdkPixbuf.PixbufLoader()
loader.set_size (size, size)
loader.write(page)
loader.close()
return loader.get_pixbuf()
def got_data(page, url, size):
__buddy_cache[url] = page
return load_thumb(page, size)
if int(data.get("iconfarm")) > 0:
url = "http://farm%s.static.flickr.com/%s/buddyicons/%s.jpg" % (data.get("iconfarm"), data.get("iconserver"), data.get("nsid"))
else:
url = "http://www.flickr.com/images/buddyicon.jpg"
if __buddy_cache.has_key(url):
return defer.execute(load_thumb, __buddy_cache[url], size)
else:
deferred = getPage(url)
deferred.addCallback(got_data, url, size)
deferred.addErrback(log.err)
return deferred
开发者ID:greatdg,项目名称:postr,代码行数:40,代码来源:util.py
示例20: abort
def abort(self, taskid):
"""
Remove a task from the queue if it has not been run already.
"""
if not isinstance(taskid, int):
return defer.fail(failure.Failure(TypeError("an integer task id expected: %r" % taskid)))
try:
self.scheduler.pop_task(taskid)
except IndexError as e:
if taskid in list(self.finishedResults.keys()):
d = defer.fail(IndexError("Task Already Completed"))
elif taskid in self.abortPending:
d = defer.fail(IndexError("Task Already Aborted"))
elif taskid in self._pendingTaskIDs():# task is pending
self.abortPending.append(taskid)
d = defer.succeed(None)
else:
d = defer.fail(e)
else:
d = defer.execute(self._doAbort, taskid)
return d
开发者ID:sunqiang,项目名称:ipython-py3k,代码行数:22,代码来源:task.py
注:本文中的twisted.internet.defer.execute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论