Whenever I try to subscribe I get TypeError: Passing coroutines is forbidden, use tasks explicitly." }
Here is the traceback
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\promise\promise.py", line 87, in try_catch
return (handler(*args, **kwargs), None)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\graphql\execution\executor.py", line 127, in promise_executor
return execute_operation(exe_context, exe_context.operation, root_value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\graphql\execution\executor.py", line 180, in execute_operation
return subscribe_fields(exe_context, type, root_value, fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\graphql\execution\executor.py", line 297, in subscribe_fields
result = subscribe_field(
^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\graphql\execution\executor.py", line 422, in subscribe_field
raise result
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\graphql\execution\executor.py", line 452, in resolve_or_error
return executor.execute(resolve_fn, source, info, **args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\graphql\execution\executors\asyncio.py", line 74, in execute
result = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\channels_graphql_ws\graphql_ws_consumer.py", line 596, in register_middleware
return next_middleware(root, info, *args, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\channels_graphql_ws\subscription.py", line 434, in _subscribe
return register_subscription(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend\env\Lib\site-packages\asgiref\sync.py", line 277, in __call__
return call_result.result()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 401, in __get_result
raise self._exception
File "C:\Users\Hp\Documents\Exercises\lssya\backend - Copy - Copy\env\Lib\site-packages\asgiref\sync.py", line 353, in main_wrap
result = await self.awaitable(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Hp\Documents\Exercises\lssya\backend - Copy - Copy\env\Lib\site-packages\channels_graphql_ws\graphql_ws_consumer.py", line 767, in _register_subscription
await asyncio.wait(waitlist)
File "C:\Users\Hp\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 415, in wait
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
TypeError: Passing coroutines is forbidden, use tasks explicitly.
This is my consumer
class MyGraphqlWsConsumer(channels_graphql_ws.GraphqlWsConsumer):
send_keepalive_every = 30
async def on_connect(self, payload):
self.scope['user'] = await channels.auth.get_user(self.scope)
schema = schema
and my subscription is
class OnNewMessage(channels_graphql_ws.Subscription):
message = graphene.Field(MessageType)
class Arguments:
chatroom = graphene.String()
def subscribe(self, info, chatroom=None):
"""Client subscription handler."""
del info
# Specify the subscription group client subscribes to.
return [chatroom] if chatroom is not None else None
def publish(self, info, chatroom=None):
return OnNewMessage(
message=self
)