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

Garbage collection issue using python 3.8 #74

Closed
Beetix opened this issue Nov 26, 2019 · 4 comments
Closed

Garbage collection issue using python 3.8 #74

Beetix opened this issue Nov 26, 2019 · 4 comments

Comments

@Beetix
Copy link

Beetix commented Nov 26, 2019

Hi,

I've tried the getting started example.

Unfortunately it doesn't seem to work due to a garbage collection issue using python 3.8. It works fine on python 3.7 (3.7.5 to be exact).

Here is the traceback:

An open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.
Exception in callback _SelectorSocketTransport._call_connection_lost(None)
handle: <Handle _SelectorSocketTransport._call_connection_lost(None)>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 958, in _call_connection_lost
    super()._call_connection_lost(exc)
  File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 716, in _call_connection_lost
    self._protocol.connection_lost(exc)
  File "/usr/local/lib/python3.8/site-packages/gmqtt/mqtt/protocol.py", line 194, in connection_lost
    self._connection.put_package((MQTTCommands.DISCONNECT, b''))
AttributeError: 'NoneType' object has no attribute 'put_package'
Traceback (most recent call last):
  File "./gmqtt_test.py", line 62, in <module>
    loop.run_until_complete(main(host))
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "./gmqtt_test.py", line 45, in main
    await client.connect(broker_host)
  File "/usr/local/lib/python3.8/site-packages/gmqtt/client.py", line 146, in connect
    await self._connection.auth(self._client_id, self._username, self._password, will_message=self._will_message,
  File "/usr/local/lib/python3.8/site-packages/gmqtt/mqtt/connection.py", line 50, in auth
    await self._protocol.send_auth_package(client_id, username, password, self._clean_session,
  File "/usr/local/lib/python3.8/site-packages/gmqtt/mqtt/protocol.py", line 87, in send_auth_package
    self.write_data(pkg)
  File "/usr/local/lib/python3.8/site-packages/gmqtt/mqtt/protocol.py", line 42, in write_data
    if not self._transport.is_closing():
AttributeError: 'NoneType' object has no attribute 'is_closing'

You can reproduce this by using the python 3.8-buster docker image:

host> docker run -it -v $SCRIPT_PATH:/gmqtt_getting_started.py python:3.8-buster /bin/bash
container> pip install gmqtt
container> /gmqtt_getting_started.py

Does anyone have an idea on how to fix this?

Thanks

@Lenka42
Copy link
Collaborator

Lenka42 commented Nov 26, 2019

@Beetix thanks for bringing this up.
Seems like the problem is caused by changes in asyncio StreamReader in 3.8.0
I will investigate it further

@Beetix
Copy link
Author

Beetix commented Nov 26, 2019

Ok, great, thanks!

@Lenka42
Copy link
Collaborator

Lenka42 commented Nov 27, 2019

@Beetix try version gmqtt==0.4.5

Problem was caused by changes in asyncio.StreamReader, also this class is deprecated, so we need to get rid of this dependency later

@Beetix
Copy link
Author

Beetix commented Nov 28, 2019

@Lenka42 I confirm it works. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants