Skip to content

Chanel layer group_send bug #48

@davidsarosi92

Description

@davidsarosi92

Hi!

I use Django 4.2.3, Channels 4.0.0 and strawberry-graphql-django 0.10.6.
Python version is 3.11.4

channel_layer is channels_rabbitmq.core.RabbitmqChannelLayer

I use subscription, and I got an error message sometimes for channel_layer.group_send:

| Fatal error: protocol.data_received() call failed.
| protocol: <carehare._protocol.Protocol object at 0xffff6edd6690>
| transport: <_SelectorSocketTransport fd=17 read=polling write=<idle, bufsize=0>>
| Traceback (most recent call last):
|   File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
|     self._protocol.data_received(data)
|   File "/usr/local/lib/python3.11/site-packages/carehare/_protocol.py", line 118, in data_received
|     self._handle_buffer_frames()
|   File "/usr/local/lib/python3.11/site-packages/carehare/_protocol.py", line 170, in _handle_buffer_frames
|     self._handle_frame_or_crash(channel_id, frame)
|   File "/usr/local/lib/python3.11/site-packages/carehare/_protocol.py", line 184, in _handle_frame_or_crash
|     self.accept_frame(frame, channel_id)
|   File "/usr/local/lib/python3.11/site-packages/carehare/_protocol.py", line 212, in accept_frame
|     return self._accept_frame_after_handshake(frame, channel_id)
|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File "/usr/local/lib/python3.11/functools.py", line 946, in _method
|     return method.__get__(obj, cls)(*args, **kwargs)
|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File "/usr/local/lib/python3.11/site-packages/carehare/_protocol.py", line 220, in _accept_frame_after_handshake
|     channel.accept_frame(frame)
|   File "/usr/local/lib/python3.11/functools.py", line 946, in _method
|     return method.__get__(obj, cls)(*args, **kwargs)
|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File "/usr/local/lib/python3.11/site-packages/carehare/_exchange_channel.py", line 52, in _
|     self._delivering.pop(tag).set_result(None)
| asyncio.exceptions.InvalidStateError: invalid state

Sometimes channel_layer.group_add is stuck, I don't know, it is just waiting...

Will there be support for Python 3.11?

@strawberry.subscription
    async def inventory_count_header(self, info: Info, inventory_count_header_id: int) -> AsyncGenerator[
        InventoryCountHeaderWithInventoryItemsType, None]:
        ...

        ws = info.context.ws
        channel_layer = ws.channel_layer
        group_name = ...

        await channel_layer.group_add(group_name, ws.channel_name)

        await channel_layer.group_send(
            group_name,
            {
                'type': ...,
                'operation': ...,
                'id': ...
            },
        )

        async for message in ws.channel_listen(ChannelGroup.INVENTORY_COUNT_HEADER_TYPE.value, groups=[group_name]):
            operation: Operation = message['operation']
            ...
            yield result

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions