Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ClientConnection' object has no attribute 'path' #92

Closed
scenaristeur opened this issue Dec 9, 2024 · 0 comments · Fixed by #95
Closed

AttributeError: 'ClientConnection' object has no attribute 'path' #92

scenaristeur opened this issue Dec 9, 2024 · 0 comments · Fixed by #95
Labels
bug Something isn't working

Comments

@scenaristeur
Copy link

scenaristeur commented Dec 9, 2024

hi @davidbrochart thxs for the client demo correction but the new example with

from websockets import connect
from pycrdt import Doc, Map
from pycrdt_websocket import WebsocketProvider

async def client():
    ydoc = Doc()
    ymap = ydoc.get("map", type=Map)
    async with (
        connect("ws://localhost:1234/my-roomname") as websocket,
        WebsocketProvider(ydoc, websocket),
    ):
        # Changes to remote ydoc are applied to local ydoc.
        # Changes to local ydoc are sent over the WebSocket and
        # broadcast to all clients.
        ymap["key"] = "value"

        await asyncio.Future()  # run forever

asyncio.run(client())
``

give me an error : 

```(.venv) smag@smag-IdeaPad:~/dev/ypu/python$ python client.py 
Traceback (most recent call last):
  File "/home/smag/dev/ypu/python/client.py", line 18, in client
    await asyncio.Future()  # run forever
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f787b2808e0

During handling of the above exception, another exception occurred:

  + Exception Group Traceback (most recent call last):
  |   File "/home/smag/dev/ypu/python/client.py", line 20, in <module>
  |     asyncio.run(client())
  |   File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
  |     return loop.run_until_complete(main)
  |   File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
  |     return future.result()
  |   File "/home/smag/dev/ypu/python/client.py", line 9, in client
  |     async with (
  |   File "/home/smag/dev/ypu/python/.venv/lib/python3.10/site-packages/pycrdt_websocket/websocket_provider.py", line 133, in __aexit__
  |     return await self._exit_stack.__aexit__(exc_type, exc_value, exc_tb)
  |   File "/usr/lib/python3.10/contextlib.py", line 714, in __aexit__
  |     raise exc_details[1]
  |   File "/usr/lib/python3.10/contextlib.py", line 697, in __aexit__
  |     cb_suppress = await cb(*exc_details)
  |   File "/home/smag/dev/ypu/python/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 815, in __aexit__
  |     raise BaseExceptionGroup(
  | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/smag/dev/ypu/python/.venv/lib/python3.10/site-packages/pycrdt_websocket/websocket_provider.py", line 89, in _run
    |     self._websocket.path,
    | AttributeError: 'ClientConnection' object has no attribute 'path'

here is the websocket.__dict__

{'protocol': <websockets.client.ClientProtocol object at 0x7fae606d5360>, 'ping_interval': 20, 'ping_timeout': 20, 'close_timeout': 10, 'max_queue': (16, None), 'write_limit': (32768, None), 'id': UUID('a04adc92-2f7a-4b9f-8dd4-8da8c2c53992'), 'logger': <LoggerAdapter websockets.client (WARNING)>, 'debug': False, 'request': Request(path='/my-roomname', headers=Headers([('Host', 'localhost:1234'), ('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Key', '5qvssS4Lqxsdt7pXgdxDGA=='), ('Sec-WebSocket-Version', '13'), ('Sec-WebSocket-Extensions', 'permessage-deflate; client_max_window_bits'), ('User-Agent', 'Python/3.10 websockets/14.1')]), _exception=None), 'response': Response(status_code=101, reason_phrase='Switching Protocols', headers=Headers([('Upgrade', 'websocket'), ('Connection', 'Upgrade'), ('Sec-WebSocket-Accept', 'gt4Pwk9qBnZoW7ogg5m7uAWEsGY=')]), body=None, _exception=None), 'loop': <_UnixSelectorEventLoop running=True closed=False debug=False>, 'close_deadline': None, 'fragmented_send_waiter': None, 'pong_waiters': {}, 'latency': 0, 'keepalive_task': <Task pending name='Task-2' coro=<Connection.keepalive() running at /home/smag/dev/ypu/python/.venv/lib/python3.10/site-packages/websockets/asyncio/connection.py:797> wait_for=>, 'recv_exc': None, 'connection_lost_waiter': , 'paused': False, 'drain_waiters': deque([]), 'response_rcvd': , 'recv_messages': <websockets.asyncio.messages.Assembler object at 0x7fae606d6140>, 'transport': <_SelectorSocketTransport fd=6 read=polling write=<idle, bufsize=0>>}

``

``

@scenaristeur scenaristeur added the bug Something isn't working label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant