core (memory/storage): backend storage is now based on SQLAlchemy
This commit is contained in:
parent
1ad8de5726
commit
a5f225e1ea
1 changed files with 1335 additions and 1784 deletions
|
|
@ -28,7 +28,7 @@ import random
|
|||
import inspect
|
||||
import textwrap
|
||||
import functools
|
||||
from asyncio import iscoroutine
|
||||
import asyncio
|
||||
from twisted.python import procutils, failure
|
||||
from twisted.internet import defer
|
||||
from sat.core.constants import Const as C
|
||||
|
|
@ -102,7 +102,7 @@ def asDeferred(func, *args, **kwargs):
|
|||
except Exception as e:
|
||||
return defer.fail(failure.Failure(e))
|
||||
else:
|
||||
if iscoroutine(ret):
|
||||
if asyncio.iscoroutine(ret):
|
||||
return defer.ensureDeferred(ret)
|
||||
elif isinstance(ret, defer.Deferred):
|
||||
return ret
|
||||
|
|
@ -112,6 +112,20 @@ def asDeferred(func, *args, **kwargs):
|
|||
return defer.succeed(ret)
|
||||
|
||||
|
||||
def aio(func):
|
||||
"""Decorator to return a Deferred from asyncio coroutine
|
||||
|
||||
Functions with this decorator are run in asyncio context
|
||||
"""
|
||||
def wrapper(*args, **kwargs):
|
||||
return defer.Deferred.fromFuture(asyncio.ensure_future(func(*args, **kwargs)))
|
||||
return wrapper
|
||||
|
||||
|
||||
def as_future(d):
|
||||
return d.asFuture(asyncio.get_event_loop())
|
||||
|
||||
|
||||
def xmpp_date(timestamp=None, with_time=True):
|
||||
"""Return date according to XEP-0082 specification
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue