How to use the asgiref.sync.SyncToAsync.__init__ function in asgiref

To help you get started, we’ve selected a few asgiref examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oTree-org / otree-core / otree_startup / __init__.py View on Github external
# https://github.com/django/asgiref/issues/179
from asgiref.sync import SyncToAsync

old_init = SyncToAsync.__init__


def _thread_sensitive_init(self, func, thread_sensitive=True):
    return old_init(self, func, thread_sensitive=True)


SyncToAsync.__init__ = _thread_sensitive_init

import json
import logging
import django.core.management
import django.conf
import os
import sys
from sys import argv
from collections import OrderedDict, defaultdict
from pathlib import Path
from typing import Optional

# avoid confusion with otree_startup.settings
from django.conf import settings as django_settings
from importlib import import_module
from django.core.management import get_commands, load_command_class
github oTree-org / otree-core / otree_startup / __init__.py View on Github external
# https://github.com/django/asgiref/issues/179
from asgiref.sync import SyncToAsync

old_init = SyncToAsync.__init__


def _thread_sensitive_init(self, func, thread_sensitive=True):
    return old_init(self, func, thread_sensitive=True)


SyncToAsync.__init__ = _thread_sensitive_init

import json
import logging
import django.core.management
import django.conf
import os
import sys
from sys import argv
from collections import OrderedDict, defaultdict