本文整理匯總了Python中r2.models.trylater.TryLater類的典型用法代碼示例。如果您正苦於以下問題:Python TryLater類的具體用法?Python TryLater怎麽用?Python TryLater使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TryLater類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: delete
def delete(self, delete_message=None):
self.delete_message = delete_message
self.delete_time = datetime.now(g.tz)
self._deleted = True
self._commit()
# update caches
Account._by_name(self.name, allow_deleted=True, _update=True)
# we need to catch an exception here since it will have been
# recently deleted
try:
Account._by_name(self.name, _update=True)
except NotFound:
pass
# remove from friends lists
q = Friend._query(Friend.c._thing2_id == self._id, Friend.c._name == "friend", eager_load=True)
for f in q:
f._thing1.remove_friend(f._thing2)
q = Friend._query(Friend.c._thing2_id == self._id, Friend.c._name == "enemy", eager_load=True)
for f in q:
f._thing1.remove_enemy(f._thing2)
# wipe out stored password data after a recovery period
TryLater.schedule("account_deletion", self._id36, delay=timedelta(days=90))
# Remove OAuth2Client developer permissions. This will delete any
# clients for which this account is the sole developer.
from r2.models.token import OAuth2Client
for client in OAuth2Client._by_developer(self):
client.remove_developer(self)
示例2: _check_edits
def _check_edits(link):
checking_edits = getattr(link, "dfp_checking_edits", False)
if not checking_edits:
TryLater.schedule("dfp_check_edits", link._fullname, timedelta(minutes=5))
link.dfp_checking_edits = True
link._commit()
示例3: run_trylater
def run_trylater():
our_hooks = (key[len(PREFIX):] for key in all_hooks().keys()
if key.startswith(PREFIX))
with TryLater.multi_handle(our_hooks) as handleable:
for system, data in handleable.iteritems():
hook_name = "trylater.%s" % system
g.log.info("Trying %s", system)
get_hook(hook_name).call(data=data)
amqp.worker.join()
示例4: delete
def delete(self, delete_message=None):
self.delete_message = delete_message
self.delete_time = datetime.now(g.tz)
self._deleted = True
self._commit()
# update caches
Account._by_name(self.name, allow_deleted=True, _update=True)
# we need to catch an exception here since it will have been
# recently deleted
try:
Account._by_name(self.name, _update=True)
except NotFound:
pass
# Mark this account for immediate cleanup tasks
amqp.add_item("account_deleted", self._fullname)
# schedule further cleanup after a possible recovery period
TryLater.schedule("account_deletion", self._id36, delay=timedelta(days=90))