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

error at telnet shutdown in Python 3 #2702

Open
kmike opened this issue Apr 5, 2017 · 7 comments
Open

error at telnet shutdown in Python 3 #2702

kmike opened this issue Apr 5, 2017 · 7 comments
Labels

Comments

@kmike
Copy link
Member

kmike commented Apr 5, 2017

Scrapy version:

Scrapy    : 1.3.3
lxml      : 3.7.3.0
libxml2   : 2.9.3
cssselect : 1.0.1
parsel    : 1.1.0
w3lib     : 1.17.0
Twisted   : 17.1.0
Python    : 3.5.2 (default, Nov 17 2016, 17:05:23) - [GCC 5.4.0 20160609]
pyOpenSSL : 0.15.1 (OpenSSL 1.0.2g  1 Mar 2016)
Platform  : Linux-4.4.0-59-generic-x86_64-with-Ubuntu-16.04-xenial

I've got this exception on shutdown:

2017-04-05 18:18:10 [scrapy.core.engine] INFO: Spider closed (finished)
2017-04-05 18:18:10 [scrapy.utils.signal] ERROR: Error caught on signal handler: <bound method TelnetConsole.stop_listening of <scrapy.extensions.telnet.TelnetConsole object at 0x7fbb993bfeb8>>
Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/pydispatch/robustapply.py", line 55, in robustApply
    return receiver(*arguments, **named)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/scrapy/extensions/telnet.py", line 63, in stop_listening
    self.port.stopListening()
AttributeError: 'TelnetConsole' object has no attribute 'port'

Not sure if it is a real problem, but it'd be nice to shut down without error messages. No idea how to reproduce it, I've only seen it once.

@timfeirg
Copy link

I'm using scrapy 1.3.3 with python 3.6.1, didn't see this while using the telnet console

cclauss pushed a commit to cclauss/scrapy that referenced this issue Aug 21, 2017
Fixes  scrapy#2702 by only call self.port.stopListening() if self.start_listening() has already been called.
@cclauss
Copy link

cclauss commented Aug 21, 2017

This would happen if the TelnetConsole was initialzed but never had its start_listening() method called because self.port is currently not defined in the former but is only defined in the latter.

Fix proposed in #2892

@Gallaecio
Copy link
Member

Should we close this until there is a way to reproduce it?

@cclauss
Copy link

cclauss commented Feb 16, 2024

As discussed above, there is a way of reproducing it. Initialize the TelnetConsole but do not call its .start_listening() method.

@Gallaecio
Copy link
Member

I don't understand why the error happens in a first place - why can start_listening call be missed
#2892 (comment)

cclauss added a commit to cclauss/scrapy that referenced this issue Feb 16, 2024
Class variables should always be initialized in the `.__init__()` method but `TerminalConsole.port` is not.  As discussed in:
* scrapy#2702
* scrapy#2892
@Gallaecio
Copy link
Member

@cclauss My understanding is that the original issue was triggered without manually interacting with the TelnetConsole class. So there is no human interaction with the class itself. Which means that the root issue most likely could be (or have been?) in some other code that directly or indirectly handles the TelnetConsole class. And #6224 would hide that issue (again, if such an issue currently exists, which is not clear).

@cclauss
Copy link

cclauss commented Feb 16, 2024

The original request was:

Not sure if it is a real problem, but it'd be nice to shut down without error messages. No idea how to reproduce it, I've only seen it once.

I broke that down into two requests:

it'd be nice to shut down without error messages

That was #2892

No idea how to reproduce it

That was #6224

If you do not want questions answered then please refrain from opening issues.

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

No branches or pull requests

4 participants