0

我使用 django 频道并在收到消息时收到此异常:

2017-07-27 08:34:56,241 - DEBUG - worker - Got message on websocket.receive (reply daphne.response.key)
2017-07-27 08:34:56,242 - DEBUG - runworker - websocket.receive
2017-07-27 08:34:56,242 - DEBUG - worker - Dispatching message on websocket.receive to project.consumers.ws_message
Traceback (most recent call last):
  File "/project/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/channels/management/commands/runworker.py", line 83, in handle
    worker.run()
  File "/usr/local/lib/python2.7/dist-packages/channels/worker.py", line 151, in run
    consumer_finished.send(sender=self.__class__)
  File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 193, in send
    for receiver in self._live_receivers(sender)
  File "/usr/local/lib/python2.7/dist-packages/channels/message.py", line 105, in send_and_flush
    sender.send(message, immediately=True)
  File "/usr/local/lib/python2.7/dist-packages/channels/channel.py", line 88, in send
    self.channel_layer.send_group(self.name, content)
  File "/usr/local/lib/python2.7/dist-packages/asgi_ipc/core.py", line 130, in send_group
    for channel in self.group_channels(group):
  File "/usr/local/lib/python2.7/dist-packages/asgi_ipc/core.py", line 137, in group_channels
    return self.group_store.flush_expired(group)
  File "/usr/local/lib/python2.7/dist-packages/asgi_ipc/store.py", line 188, in flush_expired
    for item, expiry in value[name].items()
KeyError: u'None'
2017-07-27 08:34:57,719 - INFO - runworker - Using single-threaded worker.
2017-07-27 08:34:57,719 - INFO - runworker - Running worker against channel layer default (asgi_ipc.core.IPCChannelLayer)
2017-07-27 08:34:57,719 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive

ws_message代码:

@channel_session
def ws_message(message):
    order_id = int(message.content['text'])
    order = Order.objects.get(pk=order_id)

    artist_id = message.channel_session["user_id"]
    artist = Artist.objects.get(user=User.objects.get(pk=artist_id))

    order.artist = artist

    Group(str(order.client.id)).send({'bytes': json.dumps({'time': str(order.time),
                                                           'name': artist.user.first_name + " " + artist.user.last_name})})

我究竟做错了什么?

4

1 回答 1

0

一个str(order.client.id)'None'

似乎是asgi_ipc刷新过期组的错误。asgi_ipc查看flush_expired的实际来源

asgi_ipc源必须是测试 -if name in valueflush_expired

1) 尝试更新channelsasgi_ipc 2) 报告问题asgi_ipc

于 2017-07-27T11:01:03.773 回答