Skip to content

Commit

Permalink
Merge pull request #75 from StuBz211/fix/eventlet_rlock
Browse files Browse the repository at this point in the history
Fix eventlet rlock using as context manager
  • Loading branch information
jneight authored Jan 14, 2024
2 parents 4b5e050 + cfadb44 commit 93cc42f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
from gevent.lock import RLock
except ImportError:
from eventlet import queue
from ...utils import nullcontext

def RLock():
return nullcontext
from ...utils import NullContextRLock as RLock

try:
from psycopg2 import connect, DatabaseError
Expand Down
12 changes: 9 additions & 3 deletions django_db_geventpool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ def wrapper(*args, **kwargs):
return wrapper


@contextmanager
def nullcontext(enter_result=None):
yield enter_result
class NullContextRLock:
def __init__(self, enter_result=None):
self._enter_result = enter_result

def __enter__(self):
return self._enter_result

def __exit__(self, exc_type, exc_val, exc_tb):
return None

0 comments on commit 93cc42f

Please sign in to comment.