hyperspyUI icon indicating copy to clipboard operation
hyperspyUI copied to clipboard

Calling HyperSpyUI when another instace is active.

Open francisco-dlp opened this issue 7 years ago • 23 comments

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?

francisco-dlp avatar Apr 15 '17 11:04 francisco-dlp

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

vidartf avatar Apr 15 '17 11:04 vidartf

(the relevant file to debug is single_application.py)

vidartf avatar Apr 15 '17 11:04 vidartf

qt 4.8.7, pyqt 4.11.4

francisco-dlp avatar Apr 15 '17 11:04 francisco-dlp

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

vidartf avatar Apr 15 '17 11:04 vidartf

Still refusing with 10000

francisco-dlp avatar Apr 15 '17 11:04 francisco-dlp

Do you see any log output from the existing instance?

vidartf avatar Apr 15 '17 11:04 vidartf

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.

francisco-dlp avatar Apr 15 '17 11:04 francisco-dlp

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 avatar Apr 15 '17 11:04 vidartf

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)?

vidartf avatar Apr 15 '17 11:04 vidartf

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

There is nothing special about my localhost AFAICT.

francisco-dlp avatar Apr 15 '17 11:04 francisco-dlp

It works for me in Windows.

francisco-dlp avatar Apr 15 '17 12:04 francisco-dlp

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.

vidartf avatar Apr 15 '17 14:04 vidartf

I get Exiting early!

francisco-dlp avatar Apr 15 '17 14:04 francisco-dlp

When running the first one?

vidartf avatar Apr 15 '17 14:04 vidartf

No, the first one is fine Loaded app

francisco-dlp avatar Apr 15 '17 14:04 francisco-dlp

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!

vidartf avatar Apr 15 '17 14:04 vidartf

In Windows?

francisco-dlp avatar Apr 15 '17 14:04 francisco-dlp

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 avatar Apr 15 '17 18:04 vidartf

Simply running py.test should do.

vidartf avatar Apr 15 '17 18:04 vidartf

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 avatar Apr 15 '17 20:04 francisco-dlp

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.

francisco-dlp avatar Apr 16 '17 06:04 francisco-dlp

@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 avatar Apr 16 '17 13:04 vidartf

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

vidartf avatar Apr 16 '17 14:04 vidartf