tools (utils): new ensure_deferred decorator
This commit is contained in:
parent
6c853262e1
commit
893e8e7a96
1 changed files with 11 additions and 0 deletions
|
|
@ -126,6 +126,17 @@ def as_future(d):
|
|||
return d.asFuture(asyncio.get_event_loop())
|
||||
|
||||
|
||||
def ensure_deferred(func):
|
||||
"""Decorator to apply ensureDeferred to a function
|
||||
|
||||
to be used when the function is called by third party library (e.g. wokkel)
|
||||
Otherwise, it's better to use ensureDeferred as early as possible.
|
||||
"""
|
||||
def wrapper(*args, **kwargs):
|
||||
return defer.ensureDeferred(func(*args, **kwargs))
|
||||
return wrapper
|
||||
|
||||
|
||||
def xmpp_date(timestamp=None, with_time=True):
|
||||
"""Return date according to XEP-0082 specification
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue