本文整理汇总了Python中uwsgi.spool函数的典型用法代码示例。如果您正苦于以下问题:Python spool函数的具体用法?Python spool怎么用?Python spool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.addCleanup(cleanTasks)
for priority, name in constants.tasks:
task = {'name': name, 'at': int(time.time() + 10)}
if priority is not None:
task['priority'] = str(priority)
uwsgi.spool(task)
示例2: notify
def notify(self, thread, comment):
body = self.format(thread, comment)
if uwsgi:
uwsgi.spool({b"subject": thread["title"].encode("utf-8"), b"body": body.encode("utf-8")})
else:
start_new_thread(self._retry, (thread["title"], body))
示例3: sendmail
def sendmail(self, subject, body, thread, comment, to=None):
to = to or self.conf.get("to")
if uwsgi:
uwsgi.spool({b"subject": subject.encode("utf-8"),
b"body": body.encode("utf-8"),
b"to": to.encode("utf-8")})
else:
start_new_thread(self._retry, (subject, body, to))
示例4: start_processing
def start_processing(cls, att):
try:
import uwsgi
uwsgi.spool({b"processor": cls.__name__.encode(), b"id": str(att.id).encode()})
except Exception as exc:
print("Not running in uWSGI env. Executing in foreground: {}".format(exc))
proc = cls(att)
return proc.process()
示例5: delay
def delay(cls, *args, **kwargs):
id = str(uuid.uuid4())
kwargs['language'] = translation.get_language()
import uwsgi
uwsgi.spool({
'task': pickle.dumps(cls(id)),
'args': pickle.dumps(args),
'kwargs': pickle.dumps(kwargs),
})
return TaskStatus(id)
示例6: monitor_changes
def monitor_changes(db):
previous_seq = 0
count = 0
while True:
stream = ChangesStream(db, feed="continuous",
heartbeat=True, since=previous_seq)
log.debug("pull from changes")
for c in stream:
previous_seq = c['seq']
count += 1
if count % 100 == 0:
log.debug("updating views")
try:
uwsgi.spool({"action": _UPDATE_VIEW, "uri": db.uri})
except:
pass
示例7: __call__
def __call__(self, *args, **kwargs):
arguments = self.base_dict
if len(args) > 0:
arguments.update(args[0])
if kwargs:
arguments.update(kwargs)
return uwsgi.spool(arguments)
示例8: spool
def spool(self, *args, **kwargs):
arguments = self.base_dict
arguments["ud_spool_ret"] = str(uwsgi.SPOOL_RETRY)
if len(args) > 0:
arguments.update(args[0])
if kwargs:
arguments.update(kwargs)
return uwsgi.spool(arguments)
示例9: application
def application(env, start_response):
name = uwsgi.spool({'Hello':'World', 'I am a':'long running task'})
print("spooled as %s" % name)
start_response('200 Ok', [('Content-Type','text/plain'),('uWSGI-Status', 'spooled')])
return "task spooled"
示例10: hello
def hello():
try:
# NOTE: simulate a failure.
if randint(1, 5) == 1:
raise Exception("this is the end")
mkey = mclient.get("sleep")
if mkey:
return "Hello World from cache :: {} !".format(mkey)
# NOTE: simulate a long operation.
print("sleep my friend !")
time.sleep(5)
mclient.set("sleep", "Hearth of the Swarm")
return "Hello World !"
except Exception as e:
uwsgi.spool({'name': 'Wings of liberty'})
return "Hello World with failure !"
示例11: __call__
def __call__(self, *args, **kwargs):
arguments = self.base_dict
if not self.pass_arguments:
if len(args) > 0:
arguments.update(args[0])
if kwargs:
arguments.update(kwargs)
else:
spooler_args = {}
for key in ('message_dict', 'spooler', 'priority', 'at', 'body'):
if key in kwargs:
spooler_args.update({key: kwargs.pop(key)})
arguments.update(spooler_args)
arguments.update({'args': pickle.dumps(args), 'kwargs': pickle.dumps(kwargs)})
return uwsgi.spool(arguments)
示例12: mule
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""We need this mule because we can't uwsgi.spool in a greenlet.
To resolve this problem, we send a message from the greenlet to the mule (that
IS part of the uWSGI stack, not only having the context), that itself transmits
the message on the spool.
"""
import ast
import uwsgi
while True:
message = uwsgi.mule_get_msg()
if message:
message = ast.literal_eval(message)
uwsgi.spool(message)
示例13: spooler_func
# uwsgi --master --plugins=python27 --spooler=/var/spool/uwsgi/ --spooler-import spooler_dir.py
import uwsgi
def spooler_func(env):
print(uwsgi.spooler_dir())
return uwsgi.SPOOL_RETRY
uwsgi.spooler = spooler_func
uwsgi.spool({"foo": "bar"})
示例14: notify
def notify(self, subject, body, retries=5):
uwsgi.spool({"subject": subject.encode('utf-8'), "body": body.encode('utf-8')})
示例15: producer
def producer():
uwsgi.spool(ud_spool_func="consumer", dest=random.choice(projects))
time.sleep(2)