rkdrnwkd17316
@rkdrnwkd17316
Reviews Written
-
Average Rating
-
Posts
Q&A
run_test_hello_channel.py ์ค๋ฅ
์ฝ๋ ๋ฐ์์ ๋๋ ค๋ดค๋๋ฐ ์ ๋์๊ฐ๋ค์..์ด๋์ ๊ฐ ์ฝ๋๋ฅผ ์๋ชป ์ป๋๋ด์ ๊ฐ์ฌํฉ๋๋ค!
- 0
- 4
- 601
Q&A
run_test_hello_channel.py ์ค๋ฅ
#!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) if __name__ == '__main__': main()manage.py์ ๊ฒฝ๋ก์ค์ ๋ผ์์ต๋๋ค.layers๊ฐ์ ์ ์์ ์ผ๋ก ์ถ๋ ฅ๋ฉ๋๋ค. ~/Documents/GitHub/Quickie test-chat !3 > python3 run_test_hello_channel.py 4s py Quickie 13:59:04 {โdefaultโ: {โBACKENDโ: โchannels_redis.core.RedisChannelLayerโ, โCONfIGโ: {โhostsโ: [{โhostโ: โredis-11279.c54.ap-northeast-1-2.ec2.cloud.redislabs.comโ, โportโ: 11279, โpasswordโ: โlRiJKj6xSMpubVvQ2QLNeft05INxmItmvโ}]}}} RedisChannelLayer(hosts=[{โaddressโ: โredis://localhost:6379โ}]) Traceback (most recent call last): File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/redis/asyncio/connection.pyโ, line 567, in connect await self.retry.call_with_retry( File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/redis/asyncio/retry.pyโ, line 59, in call_with_retry return await do() File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/redis/asyncio/connection.pyโ, line 604, in _connect reader, writer = await asyncio.open_connection( File โ/Users/kang-yongmin/.pyenv/versions/3.10.4/lib/python3.10/asyncio/streams.pyโ, line 47, in open_connection transport, _ = await loop.create_connection( File โ/Users/kang-yongmin/.pyenv/versions/3.10.4/lib/python3.10/asyncio/base_events.pyโ, line 1072, in create_connection raise OSError(โMultiple exceptions: {}โ.format( OSError: Multiple exceptions: [Errno 61] Connect call failed (โ::1โ, 6379, 0, 0), [Errno 61] Connect call failed (โ127.0.0.1โ, 6379) During handling of the above exception, another exception occurred: Traceback (most recent call last): File โ/Users/kang-yongmin/Documents/GitHub/Quickie/run_test_hello_channel.pyโ, line 25, in asyncio.run(main()) File โ/Users/kang-yongmin/.pyenv/versions/3.10.4/lib/python3.10/asyncio/runners.pyโ, line 44, in run return loop.run_until_complete(main) File โ/Users/kang-yongmin/.pyenv/versions/3.10.4/lib/python3.10/asyncio/base_events.pyโ, line 646, in run_until_complete return future.result() File โ/Users/kang-yongmin/Documents/GitHub/Quickie/run_test_hello_channel.pyโ, line 19, in main await channel_layer.send(โhelloโ, message_dict) File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/channels_redis/core.pyโ, line 218, in send await connection.zremrangebyscore( File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/redis/asyncio/client.pyโ, line 502, in execute_command conn = self.connection or await pool.get_connection(command_name, **options) File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/redis/asyncio/connection.pyโ, line 1363, in get_connection await connection.connect() File โ/Users/kang-yongmin/Documents/GitHub/Quickie/venv/lib/python3.10/site-packages/redis/asyncio/connection.pyโ, line 575, in connect raise ConnectionError(self._error_message(e)) redis.exceptions.ConnectionError: Error connecting to localhost:6379. Multiple exceptions: [Errno 61] Connect call failed (โ::1โ, 6379, 0, 0), [Errno 61] Connect call failed (โ127.0.0.1โ, 6379).
- 0
- 4
- 601
Q&A
run_test_hello_channel.py ์ค๋ฅ
redislabs์ ์๋ฒ๋ฅผ ์ฌ์ฉํ๋ คํ๊ณ ์์ต๋๋ค.settings.py""" Django settings for mysite project. Generated by 'django-admin startproject' using Django 4.1.5. For more information on this file, see https://docs.djangoproject.com/en/4.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.1/ref/settings/ """ from pathlib import Path from environ import Env # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent env = Env() env_path = BASE_DIR / ".env" if env_path.exists(): with env_path.open(encoding="utf8") as f: env.read_env(f, overwrite=True) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-zlx#3$sp$wca%lnq2k4)6@lz+8aak(n!buko-%(o8=__!ht=5o' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'channels', 'daphne', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'app', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'mysite.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'mysite.wsgi.application' ASGI_APPLICATION = 'mysite.asgi.application' # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } #django channels layer if "CHANNEL_LAYER_REDIS_URL" in env: channel_layer_redis = env.db_url("CHANNEL_LAYER_REDIS_URL") CHANNEL_LAYERS = { "default" : { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONfIG": { "hosts": [ { "host": channel_layer_redis["HOST"], "port": channel_layer_redis.get("PORT") or 6379, "password": channel_layer_redis["PASSWORD"], } ] } } } # Password validation # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.1/howto/static-files/ STATIC_URL = 'static/' # Default primary key field type # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' .envCHANNEL_LAYER_REDIS_URL=redis://:lRiJKj6xSMpubVvQ2QLNft05INxmItmv@redis-11279.c54.ap-northeast-1-2.ec2.cloud.redislabs.com:11279 ์์์๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์๋ํ๊ณ ์์ต๋๋ค.~/Documents/GitHub/Quickie test-chat !3 > python3 manage.py shell 37s py Quickie 13:41:59 Python 3.10.4 (main, Jan 3 2023, 21:09:20) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin Type โhelpโ, โcopyrightโ, โcreditsโ or โlicenseโ for more information. (InteractiveConsole) >>> from django.conf import settings >>> print(settings.CHANNEL_LAYERS) {โdefaultโ: {โBACKENDโ: โchannels_redis.core.RedisChannelLayerโ, โCONfIGโ: {โhostsโ: [{โhostโ: โredis-11279.c54.ap-northeast-1-2.ec2.cloud.redislabs.comโ, โportโ: 11279, โpasswordโ: โlRiJKj6xSMpubVvQ2QLNft05INxmItmvโ}]}}} >>> exit()
- 0
- 4
- 601




