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: 'SSLProtocol' object has no attribute 'data_received' inside Toga.App, but in vanilla not #1588

Closed
bitstuffing opened this issue Jan 3, 2024 · 1 comment
Labels
bug A crash or error in behavior.

Comments

@bitstuffing
Copy link

bitstuffing commented Jan 3, 2024

Describe the bug

When I tried to open a ws throw briefcase it breaks, but the same code works perfectly.
It happens:

Exception in callback ReadTransport._loop_reading(<Future finis...\x00\x00\x00'>)
handle: <GLibHandle ReadTransport._loop_reading(<Future finis...\x00\x00\x00'>)>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/user/workspace/pychat/build/pychat/endeavouros/rolling/pychat-0.0.1/usr/lib/pychat/app_packages/gbulb/transports.py", line 177, in _loop_reading
    self._submit_read_data(data)
  File "/home/user/workspace/pychat/build/pychat/endeavouros/rolling/pychat-0.0.1/usr/lib/pychat/app_packages/gbulb/transports.py", line 127, in _submit_read_data
    self._protocol.data_received(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SSLProtocol' object has no attribute 'data_received'

I have prepared a dummy demostration script for that reason:

import aiohttp
from aiohttp import ClientSession

import asyncio

url = "wss://demo.piesocket.com/v3/channel_123"

ws_headers = {
    'Origin': 'https://www.piesocket.com',
    'Sec-WebSocket-Extensions': 'permessage-deflate; client_max_window_bits',
    'Sec-WebSocket-Version': '13',
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) '
                  'AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/90.0.4430.212 Safari/537.36',
}

async def run_init_conversation(prompt="hello world!", cookies = ''):
    async with ClientSession(headers=ws_headers, cookies=cookies, timeout=aiohttp.ClientTimeout(total=60)) as session:
        async with session.ws_connect(url, autoping=False, params={'api_key': "VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV"}) as wss:
            print("Connected to test")


if __name__ == '__main__':
    asyncio.run(run_init_conversation())

or simply add this code to a dummy Toga App:

self.add_background_task(self.background)

and the definitions:


    def background(self, widget, **kwargs):
        task = self.run_init_conversation()
        asyncio.run_coroutine_threadsafe(task, self.loop)

    async def run_init_conversation(self, prompt="hello world!", cookies = ''):
        async with ClientSession(headers=ws_headers, cookies=cookies, timeout=aiohttp.ClientTimeout(total=60)) as session:
            async with session.ws_connect(url, autoping=False, params={'api_key': "VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV"}) as wss:
                print("Connected to test")

Steps to reproduce

briefcase build linux
briefcase run linux
Execute the code attached

Expected behavior

in screen it should print Connected to test but weird exception appears

Screenshots

No response

Environment

  • Operating System: EndeavourOS & Gnome Shell
  • Python version: 3.11.6
  • Software versions:
    • Briefcase: 0.3.16
    • Toga: 0.4.1
    • Toga-Core: 0.4.1
    • aiohttp: 3.9.1
    • asyncio: 3.4.3

Logs

Exception in callback ReadTransport._loop_reading(<Future finis...xd3|\xbe\x05'>)
handle: <GLibHandle ReadTransport._loop_reading(<Future finis...xd3|\xbe\x05'>)>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/user/workspace/pychat/build/pychat/endeavouros/rolling/pychat-0.0.1/usr/lib/pychat/app_packages/gbulb/transports.py", line 177, in _loop_reading
    self._submit_read_data(data)
  File "/home/user/workspace/pychat/build/pychat/endeavouros/rolling/pychat-0.0.1/usr/lib/pychat/app_packages/gbulb/transports.py", line 127, in _submit_read_data
    self._protocol.data_received(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SSLProtocol' object has no attribute 'data_received'

Additional context

No response

@bitstuffing bitstuffing added the bug A crash or error in behavior. label Jan 3, 2024
@freakboy3742
Copy link
Member

Duplicate of beeware/gbulb#116.

The immediate workaround is to downgrade to Python 3.10 or earlier.

@freakboy3742 freakboy3742 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

2 participants