Opened 6 years ago

Closed 5 years ago

#5224 defect closed duplicate (duplicate)

Strange exception in twisted.names.client.Resolver

Reported by: 平芜泫 Owned by: Retenodus
Priority: normal Milestone:
Component: names Keywords: connectionLost, AttributeError, Resolver
Cc: Retenodus Branch:
Author:

Description (last modified by Jean-Paul Calderone)

I managed to extend twisted.names.client.Resolver, and use queryTCP to fire a request. However, a strange exception "exceptions.AttributeError: UpstreamResolver instance has no attribute 'connectionLost'" occurred whenever I destroyed the client.

I tried to add an empty function named 'connectionLost' into the Resolver, and the exception never raised again.

Here I attached the final python script file. You may delete the function 'connectionLost' and see the following traceback:

Unhandled Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 286, in addCallbacks
    self._runCallbacks()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 542, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 426, in _continueFiring
    callable(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 615, in disconnectAll
    failure.Failure(main.CONNECTION_LOST))
--- <exception caught here> ---
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/log.py", line 69, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 687, in connectionLost
    Connection.connectionLost(self, reason)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 529, in connectionLost
    protocol.connectionLost(reason)
  File "/usr/local/lib/python2.7/dist-packages/twisted/names/dns.py", line 1856, in connectionLost
    self.controller.connectionLost(self)
exceptions.AttributeError: UpstreamResolver instance has no attribute 'connectionLost'

Attachments (3)

resolvers.py (1.9 KB) - added by 平芜泫 6 years ago.
The resolver script.
5224.patch (376 bytes) - added by Retenodus 6 years ago.
5224.2.patch (460 bytes) - added by Retenodus 6 years ago.

Download all attachments as: .zip

Change History (10)

Changed 6 years ago by 平芜泫

Attachment: resolvers.py added

The resolver script.

comment:1 Changed 6 years ago by Jean-Paul Calderone

Description: modified (diff)
Milestone: Twisted-11.1

Fixing description markup and removing milestone. Release milestones are generally only for regressions.

Changed 6 years ago by Retenodus

Attachment: 5224.patch added

comment:2 Changed 6 years ago by Retenodus

Cc: Retenodus added

I've added a connectionLost to twisted.names.client.Resolver. The problem is addressed and there's no problem with unittests.

I didn't added unittests because actually this method doesn't do anything.

Changed 6 years ago by Retenodus

Attachment: 5224.2.patch added

comment:3 Changed 6 years ago by Retenodus

Keywords: review added

Oops, I had forgotten the docstring.

comment:4 Changed 6 years ago by Jean-Paul Calderone

Keywords: review removed
Owner: set to Retenodus

Thanks Retendonus. The method does do something, though. It prevents an exception from being raised in a certain case. That's what the unit test should verify.

Also, you don't need pass in the body, since the docstring already gives the function its one required statement.

comment:5 Changed 6 years ago by Thijs Triemstra

Summary: Stange exception in twited.names.client.ResolverStrange exception in twisted.names.client.Resolver

comment:6 Changed 5 years ago by buddyns

Duplicate of #4015 ?

comment:7 Changed 5 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

Yes, thanks.

Note: See TracTickets for help on using tickets.