Ticket #710 (new enhancement )

Opened 4 years ago

Last modified 4 years ago

returning None from buildProtocol in ReconnectingClientFactory causes exception

Reported by: djk121 Assigned to: itamarst
Type: enhancement Priority: low
Milestone: Component:
Keywords: Cc: itamarst, teratorn, djk121
Branch: Author:
Launchpad Bug:

Attachments

Change History

  2004-09-11 02:00:20+00:00 changed by djk121

Traceback (most recent call last):
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/default.py", line 526, in
doSelect
    _logrun(selectable, _drdw, selectable, method, dict)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/python/log.py", line 65, in
callWithLogger
    callWithContext({"system": lp}, func, *args, **kw)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/python/log.py", line 52, in
callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/python/context.py", line 43, in
callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/default.py", line 535, in
_doReadOrWrite
    why = getattr(selectable, method)()
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/tcp.py", line 434, in doConnect
    self._connectDone()
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/tcp.py", line 439, in
_connectDone
    self.protocol.makeConnection(self)
exceptions.AttributeError: 'NoneType' object has no attribute 'makeConnection'
Traceback (most recent call last):
  File "server.py", line 239, in ?
    reactor.run()
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/default.py", line 126, in run
    self.mainLoop()
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/default.py", line 137, in
mainLoop
    self.doIteration(t)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/default.py", line 526, in
doSelect
    _logrun(selectable, _drdw, selectable, method, dict)
--- <exception caught here> ---
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/python/log.py", line 65, in
callWithLogger
    callWithContext({"system": lp}, func, *args, **kw)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/python/log.py", line 52, in
callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/python/context.py", line 43, in
callWithContext
    return func(*args,**kw)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/default.py", line 551, in
_doReadOrWrite
    selectable.connectionLost(failure.Failure(why))
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/tcp.py", line 447, in
connectionLost
    Connection.connectionLost(self, reason)
  File "/ita/python-2.2.2/lib/python2.2/site-packages/twisted/internet/tcp.py", line 294, in
connectionLost
    protocol.connectionLost(reason)
exceptions.AttributeError: 'NoneType' object has no attribute 'connectionLost'

  2004-11-28 02:44:31+00:00 changed by teratorn

Why would you ever return None from buildProtocol? I just glanced at the source
and this doesn't make any sense to me.

  2004-11-28 03:11:42+00:00 changed by teratorn

I'm going to change this to resolved now, because I'll probably forget about it.
If there is any good reason to not return a Protocol from buildProtocol we can
reopen it later.

  2004-11-29 09:34:30+00:00 changed by itamarst

ServerFactory allows this, as a way of automatically closing connections (we did
this on buildProtocol layer so you can have a /etc/hosts.allow|deny wrapper
factory).
The bug was reported for a casse where the client connection's only interest was
whether or not the connection succeeded, at which point the connection was
supposed to be closed. Obviously this is still easy to do without this feature,
so this is at most a wish-list item for symmetry.
Note: See TracTickets for help on using tickets.