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: 'TCPClient' object has no attribute '_tokenmanager' #279

Closed
GeorgeBateman opened this issue May 18, 2022 · 3 comments
Closed

Comments

@GeorgeBateman
Copy link

The following code:

p = await Context.create_client_context()
msg = Message(code=GET, uri="coap+tcp://127.0.0.1:5000/")
await p.request(msg).response
await p.shutdown()

results in

Aborting connection: Server shutdown
Exception in callback _SelectorSocketTransport._call_connection_lost(None)
handle: <Handle _SelectorSocketTransport._call_connection_lost(None)>
Traceback (most recent call last):
  File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 916, in _call_connection_lost
    super()._call_connection_lost(exc)
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 690, in _call_connection_lost
    self._protocol.connection_lost(exc)
  File "/home/.../.local/lib/python3.7/site-packages/aiocoap/transports/tcp.py", line 167, in connection_lost
    self._ctx._dispatch_error(self, exc)
  File "/home/.../.local/lib/python3.7/site-packages/aiocoap/transports/tcp.py", line 259, in _dispatch_error
    if self._tokenmanager is None:
AttributeError: 'TCPClient' object has no attribute '_tokenmanager'

This is apparently caused by the use of del in

del self._tokenmanager

That variable should probably be set to None instead.

@chrysn
Copy link
Owner

chrysn commented Jul 23, 2022

Yes, I mixed up the values this should have during shutdown.

Thanks for finding, this; I'm still digging around in the code a bit more to find why the tests did not report this.

@chrysn
Copy link
Owner

chrysn commented Aug 17, 2022

The reason this was not found in automated tests was because aiocoap-client didn't do proper shutdown. Now on to the underlying issue -- the change you proposed does fix it, but now the lack of proper shutdown for TCP connections start spitting warnings, fixing that.

chrysn added a commit that referenced this issue Aug 17, 2022
@chrysn chrysn closed this as completed in f24c04e Aug 17, 2022
@GeorgeBateman
Copy link
Author

Many 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