예제 #1
0
파일: asyncio.py 프로젝트: suhailvs/django
 def inner(*args, **kwargs):
     # Detect a running event loop in this thread.
     try:
         get_running_loop()
     except RuntimeError:
         pass
     else:
         if not os.environ.get('DJANGO_ALLOW_ASYNC_UNSAFE'):
             raise SynchronousOnlyOperation(message)
     # Pass onward.
     return func(*args, **kwargs)
예제 #2
0
 def inner(*args, **kwargs):
     # Detect a running event loop in this thread.
     try:
         event_loop = asyncio_实例.get_event_loop()
     except RuntimeError:
         pass
     else:
         if event_loop.is_running():
             raise SynchronousOnlyOperation(message)
     # Pass onwards.
     return func(*args, **kwargs)
예제 #3
0
 def inner(*args, **kwargs):
     if not getattr(settings, 'ALLOW_ASYNC_UNSAFE', False):
         # Detect a running event loop in this thread.
         try:
             event_loop = asyncio.get_event_loop()
         except RuntimeError:
             pass
         else:
             if event_loop.is_running():
                 raise SynchronousOnlyOperation(message)
     # Pass onwards.
     return func(*args, **kwargs)