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

Spyderlib fails to start new IPython consoles, raises socket exception #1275

Closed
spyder-bot opened this issue Feb 17, 2015 · 20 comments
Closed

Comments

@spyder-bot
Copy link
Collaborator

From jed.lud...@gmail.com on 2013-02-20T00:33:30Z

Original report from Sylvain Corlay in this thread: https://groups.google.com/d/topic/spyderlib/NF7o04Q_41M/discussion reproduced here for simplicity. Sylvain later submitted the attached patches as workarounds.


Hi,

It seems that under Ubuntu 12.04 64 bits, spyder fails to open new IPython consoles. It does start a new kernel in the "Console" widget but no console is opened in the "IPython Console" widget. However, I can still use a "connect to an existing kernel" to connect to it. A traceback is produced in the internal console:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "spyderlib/spyderlib/widgets/externalshell/introspection.py", line 62, in run
    conn, _addr = sock.accept()
  File "/usr/lib/python2.7/socket.py", line 202, in accept
    sock, addr = self._sock.accept()
error: [Errno 4] Interrupted system call

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "spyderlib/spyderlib/widgets/externalshell/introspection.py", line 62, in run
    conn, _addr = sock.accept()
  File "/usr/lib/python2.7/socket.py", line 202, in accept
    sock, addr = self._sock.accept()
error: [Errno 4] Interrupted system call

Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "spyderlib/spyderlib/spyder.py", line 1856, in start_open_files_server
    req, addr = self.open_files_server.accept()
  File "/usr/lib/python2.7/socket.py", line 202, in accept
    sock, addr = self._sock.accept()
error: [Errno 4] Interrupted system call

(When trying revisions older than revision 4a06c308b99d (Fixed crash at startup occuring when restoring Project Explorer's tree view), spyder crashes at startup. However I did not have this issue before. I can avoid this problem by deleting the configuration folder .spyder2 that does not seem to work with older versions. )

It is odd because I did not have this ipython console issue in the past with the corresponding revisions. Although there has been a few packages updated in the meanwhile.

Thanks,

S.

Attachment: introspection.diff spyder.diff

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=1275

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-19T21:39:48Z

The proposed workaround actually looks like the right way to handle the situation. Sylvain cited this example from PyPy: https://github.com/pypy/pypy/blob/master/lib-python/2.7/socket.py I did additional research and found this post: http://stackoverflow.com/questions/3016369/catching-blocking-sigint-during-system-call The man pages for accept(2) describe EINTR not so much as a failure but as the call simply being interrupted by the system: http://www.kernel.org/doc/man-pages/online/pages/man2/accept.2.html In that light, silently ignoring interrupted calls when inside infinite polling loops seems like the correct thing to do.

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-19T22:04:52Z

This issue was updated by revision 91edc30721d9 .

I implemented Sylvain's patches with minor modfication. Only Errno 4
exceptions are silently ignored. Others will still be raised.

Status: Fixed

@spyder-bot
Copy link
Collaborator Author

From ebori...@gmail.com on 2013-02-20T06:07:30Z

I would suggest using 'errno.EINTR' rather than '4'.

@spyder-bot
Copy link
Collaborator Author

From sylvain....@gmail.com on 2013-02-20T08:20:42Z

If you have other interruptible system calls in Spyder, maybe it would be a good idea to do this all the time.

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-20T09:13:34Z

I agree, although I think we'll approach this cautiously. I'd prefer to allow them to show up on a case by case basis first.

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-20T10:22:48Z

This issue was updated by revision bf42a0cb285b .

Now using errno constants instead of hard-coded integers.

@spyder-bot
Copy link
Collaborator Author

From steve.f....@gmail.com on 2013-02-20T11:15:11Z

I'm not sure if this is related or not. I just installed ipython 0.3.1 in an attempt to use it. When I try to start it from the Interpreters menu the console just shows this:
'import sitecustomize' failed; use -v for traceback
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-11624.json

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-20T12:54:45Z

@-Steve, does the IPython console eventually show up though?

@spyder-bot
Copy link
Collaborator Author

From steve.f....@gmail.com on 2013-02-20T16:09:42Z

No, it never shows up.

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-20T16:46:41Z

@-Steve: It looks like the failure is more related to your sitecustomize file not being successfully imported. Do you have a customized flavor of that file, different from what ships with Spyder by default?

@spyder-bot
Copy link
Collaborator Author

From sylvain....@gmail.com on 2013-02-22T15:33:21Z

Regarding Carlos's modification in revision 7a49c6a1cfb2 regarding the "while True:", there is another one in /spyderlib/widgets/externalshell/introspection.py

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-26T07:29:38Z

I'm not sure I understand why fractionally increasing the loop speed a the location that was modified in revision 7a49c6a1cfb2 is important. I acknowledge that there is a difference at least for Python 2.7 [1], but I just don't see why it matters.

[1] http://stackoverflow.com/questions/3815359/while-1-vs-for-whiletrue-why-is-there-a-difference

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-02-26T08:26:09Z

I think it could be useful for two reasons:

  1. To open files faster, especially if you want to open several files at once.
  2. To consume a little bit less CPU

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-02-26T08:32:33Z

@-Carlos: I have no problem with the change. Feel free to make the modification suggested by Sylvain in comment 11 if you'd like.

@spyder-bot
Copy link
Collaborator Author

From steve.f....@gmail.com on 2013-03-04T08:12:25Z

I still can't get IPython to come up.

@spyder-bot
Copy link
Collaborator Author

From jed.lud...@gmail.com on 2013-03-05T00:32:28Z

@-Steve: As mentioned in comment 10, it looks like sitecustomize.py is not loading. For reference, it's this file: https://code.google.com/p/spyderlib/source/browse/spyderlib/widgets/externalshell/sitecustomize.py Have you further customized sitecustomize.py? :)

@spyder-bot
Copy link
Collaborator Author

From jtaylor....@googlemail.com on 2013-03-15T14:45:05Z

you need these temporary failure loops on all system calls dealing with slow devices, see man 7 signal
So you should add the to the send and recv calls in spyderlib/utils/bsdsocket.py too.

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2013-03-17T07:03:03Z

@Julian (comment #18): let's do the changes in the context of issue #1106 @-Steve: see the forthcoming changeset allowing to turn on easily the verbose mode of Python interpreters executed inside Spyder. This will help you to find out the error responsible for sitecustomize failure.

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2013-03-17T07:04:34Z

This issue was updated by revision ee7ac4c9439a .

@-Steve: this is the changeset I was referring to in my previous comment.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2013-04-06T20:28:43Z

Labels: Cat-IPythonConsole

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

No branches or pull requests

1 participant