{"action":"closed","issue":{"url":"https://api.github.com/repos/django/channels/issues/1105","repository_url":"https://api.github.com/repos/django/channels","labels_url":"https://api.github.com/repos/django/channels/issues/1105/labels{/name}","comments_url":"https://api.github.com/repos/django/channels/issues/1105/comments","events_url":"https://api.github.com/repos/django/channels/issues/1105/events","html_url":"https://github.com/django/channels/issues/1105","id":341362199,"node_id":"MDU6SXNzdWUzNDEzNjIxOTk=","number":1105,"title":"question about handler","user":{"login":"vasyapupkin123456","id":9399006,"node_id":"MDQ6VXNlcjkzOTkwMDY=","avatar_url":"https://avatars1.githubusercontent.com/u/9399006?v=4","gravatar_id":"","url":"https://api.github.com/users/vasyapupkin123456","html_url":"https://github.com/vasyapupkin123456","followers_url":"https://api.github.com/users/vasyapupkin123456/followers","following_url":"https://api.github.com/users/vasyapupkin123456/following{/other_user}","gists_url":"https://api.github.com/users/vasyapupkin123456/gists{/gist_id}","starred_url":"https://api.github.com/users/vasyapupkin123456/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasyapupkin123456/subscriptions","organizations_url":"https://api.github.com/users/vasyapupkin123456/orgs","repos_url":"https://api.github.com/users/vasyapupkin123456/repos","events_url":"https://api.github.com/users/vasyapupkin123456/events{/privacy}","received_events_url":"https://api.github.com/users/vasyapupkin123456/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-15T23:40:20Z","updated_at":"2018-07-16T17:08:06Z","closed_at":"2018-07-16T17:08:06Z","author_association":"NONE","body":"Why handler chat_message run after end loop for x in range(0, 10) ? I need run handler every time when run await self.channel_layer.group_send(...)\r\n```\r\n # websocket\r\n  2 channels==2.0.2 # Asynchrony & extra protocols\r\n  1 channels_redis==2.1.1 # ASGI Redis adapter\r\n  0 websocket-client\r\n\r\n```\r\n\r\n```\r\nfrom channels.generic.websocket import AsyncWebsocketConsumer\r\nimport json\r\nfrom django.core import serializers\r\nimport time\r\nimport asyncio\r\n\r\n\r\nclass ChatConsumer(AsyncWebsocketConsumer):\r\n\r\n    async def connect(self):\r\n        self.room_name = self.scope['url_route']['kwargs']['room_name']\r\n        self.room_group_name = 'chat_%s' % self.room_name\r\n\r\n        # Join room group\r\n        await self.channel_layer.group_add(\r\n            self.room_group_name,\r\n            self.channel_name\r\n        )\r\n\r\n        await self.accept()\r\n\r\n    async def disconnect(self, close_code):\r\n        # Leave room group\r\n        await self.channel_layer.group_discard(\r\n            self.room_group_name,\r\n            self.channel_name\r\n        )\r\n\r\n    # Receive message from WebSocket\r\n    async def receive(self, text_data):\r\n        text_data_json = json.loads(text_data)\r\n        message = text_data_json['message']\r\n        \r\n        for x in range(0, 10):\r\n            await self.channel_layer.group_send(\r\n                self.room_group_name,\r\n                {\r\n                    'type': 'chat_message',\r\n                    'message': serializers.serialize(\"json\", Some.objects.all()[0:10])\r\n                }\r\n            )\r\n            await asyncio.sleep(20)\r\n    \r\n    # Receive message from room group\r\n    async def chat_message(self, event):\r\n        message = event['message']\r\n\r\n        # Send message to WebSocket\r\n        await self.send(text_data=json.dumps({\r\n            'message': message\r\n        }))\r\n```"}}
{"actor":{"display_login":"andrewgodwin"}}