summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util/_concurrency_py3k.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/util/_concurrency_py3k.py')
-rw-r--r--lib/sqlalchemy/util/_concurrency_py3k.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/sqlalchemy/util/_concurrency_py3k.py b/lib/sqlalchemy/util/_concurrency_py3k.py
index 82125b771..ee3abe5fa 100644
--- a/lib/sqlalchemy/util/_concurrency_py3k.py
+++ b/lib/sqlalchemy/util/_concurrency_py3k.py
@@ -96,17 +96,6 @@ try:
del context.driver
return result
- class AsyncAdaptedLock:
- def __init__(self):
- self.mutex = asyncio.Lock()
-
- def __enter__(self):
- await_fallback(self.mutex.acquire())
- return self
-
- def __exit__(self, *arg, **kw):
- self.mutex.release()
-
except ImportError: # pragma: no cover
greenlet = None
@@ -119,3 +108,15 @@ except ImportError: # pragma: no cover
async def greenlet_spawn(fn, *args, **kw):
raise ValueError("Greenlet is required to use this function")
+
+
+class AsyncAdaptedLock:
+ def __init__(self):
+ self.mutex = asyncio.Lock()
+
+ def __enter__(self):
+ await_fallback(self.mutex.acquire())
+ return self
+
+ def __exit__(self, *arg, **kw):
+ self.mutex.release()