hyperspy / hyperspyUI

A user interface for the hyperspy package. https://hyperspy.org/hyperspyUI
GNU General Public License v3.0
25 stars 15 forks source link

Calling HyperSpyUI when another instace is active. #130

Open francisco-dlp opened 7 years ago

francisco-dlp commented 7 years ago

Currently calling hyperspyui when an instance is active results in the following:

$ hyperspyui my_file.hdf5
QLocalSocket::connectToServer: Connection refused

Shouldn't it open the file in the current instance instead?

vidartf commented 7 years ago

Yes it should, the "Connection refused" error is relevant. Which version of Qt/PyQt/PySide are you using?

vidartf commented 7 years ago

(the relevant file to debug is single_application.py)

francisco-dlp commented 7 years ago

qt 4.8.7, pyqt 4.11.4

vidartf commented 7 years ago

That should not be a problem. Try increasing SingleApplicationWithMessaging._timeout and see if that changes anything.

francisco-dlp commented 7 years ago

Still refusing with 10000

vidartf commented 7 years ago

Do you see any log output from the existing instance?

francisco-dlp commented 7 years ago

This is all I get

ERROR:hyperspyui.singleapplication:QLocalSocket::connectToServer: Connection refused
DEBUG:hyperspyui.singleapplication:An existing instance of HyperSpyUI is running, sending arguments to it.
vidartf commented 7 years ago

PS, this uses a QLocalServer and a QLocalSocket to communicate from the secondary instance to the primary instance. Do you possibly have an interesting network config for localhost?

vidartf commented 7 years ago

This is all I get [...]

That should be the log output from the new instance of the UI. Is there anything from the existing instance (the one that is running the full UI)?

francisco-dlp commented 7 years ago

No, that one doesn't print anything to the log while attempting to connect.

There is nothing special about my localhost AFAICT.

francisco-dlp commented 7 years ago

It works for me in Windows.

vidartf commented 7 years ago

Could you download this file and run it from two different terminals? You will need to call it with an extra arg, e.g. python single_app.py test.

It should isolate the problem to a very minimal scenario.

francisco-dlp commented 7 years ago

I get Exiting early!

vidartf commented 7 years ago

When running the first one?

francisco-dlp commented 7 years ago

No, the first one is fine Loaded app

vidartf commented 7 years ago

For me, the outputs are:

First:

python single_app.py
Loaded app
<waits here until second app gets run>
["test"]

Second:

python single_app.py test
Exiting early!
francisco-dlp commented 7 years ago

In Windows?

vidartf commented 7 years ago

Could you check out the basic-CI branch on my repo? It has a test that performs those basic steps, which passes on Travis (#131).

vidartf commented 7 years ago

Simply running py.test should do.

francisco-dlp commented 7 years ago

I have not been able to reproduce the issue in my laptop computer which is running Ubuntu (my office computer runs Debian testing). So, you were right, there may be an issue with my OS. I'll check once I get to the office.

francisco-dlp commented 7 years ago

I have boiled down the problem to running hyperspyui as an application in Gnome. I have the following desktop entry:

[Desktop Entry]
Exec=/home/fjd29/anaconda3/bin/hyperspyui %F
Name=HyperSpy UI
Terminal=false
MimeType=application/x-hdf;application/x-dm3;
Icon=/home/fjd29/Python/hyperspyUI/hyperspyui/images/hyperspy.svg
Type=Application
X-MultipleArgs=true
Categories=Science;Physics;DataVisualization;

I only experience the issue when I start HyperSpyUI using this method. If I change Terminal to true I don't experience the issue any more (but I get a terminal with the app, which I don't want). When the issue triggers I have to restart in order to be able to launch hyperspyui from a terminal accepting connections. Killing hyperspyui manually doesn't work, nor login out from the gnome session.

Note: after I manage to integrate hyperspyui successfully in my gnome desktop I'll make a PR.

vidartf commented 7 years ago

@francisco-dlp : Could you try to print sys.argv on launch? I think the code might be making some assumptions about the form of that!

vidartf commented 7 years ago

No wait, that wouldn't explain the network error :-/