chocolate-icecream / pyigor

MIT License
1 stars 1 forks source link

Example code hanging #3

Open LeonLagnado opened 1 week ago

LeonLagnado commented 1 week ago

Hi, Thanks for taking this on. I have a problem with the 'Accessing Igor Pro from Python' example on my Mac using Igor Pro 8.04. Igor is opened and sine wave created, but the igor("sinwave += 1") command is not executed. When I restart the code is tells me that the queue is full. The full error message is:

Traceback (most recent call last): File "/Users/ll275/opt/anaconda3/lib/python3.9/site-packages/flask/app.py", line 1473, in wsgi_app response = self.full_dispatch_request() File "/Users/ll275/opt/anaconda3/lib/python3.9/site-packages/flask/app.py", line 882, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/ll275/opt/anaconda3/lib/python3.9/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/Users/ll275/opt/anaconda3/lib/python3.9/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/Users/ll275/opt/anaconda3/lib/python3.9/site-packages/pyigor/pyigor.py", line 136, in got_message self._queue.put_nowait(("ok", uid, None)) File "/Users/ll275/opt/anaconda3/lib/python3.9/queue.py", line 191, in put_nowait return self.put(item, block=False) File "/Users/ll275/opt/anaconda3/lib/python3.9/queue.py", line 137, in put raise Full queue.Full

Any help gratefully received!

Leon

chocolate-icecream commented 1 week ago

Thank you for reporting the issue. It seems the problem arises when Igor Pro is not already running. Here’s a detailed explanation and a possible solution:

[Possible cause]

  1. PyIgor controls Igor Pro using a shell command IgorPro -Q -X COMMAND.
  2. This command is meant to execute the specified COMMAND in an already running instance of Igor Pro. In this case, the COMMAND is PyIgorLoadWave().
  3. If Igor Pro is not running, this shell command starts Igor Pro as a subprocess.
  4. The call to subprocess.run([executable_path, "-Q", "-X", command]) in line 35 does not complete while the subprocess is running, which prevents the next command from being executed and causes the issue you reported.

[Solution] To avoid this problem, make sure Igor Pro is running before executing the PyIgor commands.

Additionally, a similar issue can occur if the Command key is held down while executing commands, as this also causes IgorPro -Q -X COMMAND to start a new process.

Please let me know if the issue continues.

LeonLagnado commented 1 week ago

Thanks so much! Works now. Looking forward to using PyIgor.

All the best,

Leon

From: chocolate-icecream @.> Date: Thursday, 20 June 2024 at 17:22 To: chocolate-icecream/pyigor @.> Cc: Leon Lagnado @.>, Author @.> Subject: Re: [chocolate-icecream/pyigor] Example code hanging (Issue #3)

Thank you for reporting the issue. It seems the problem arises when Igor Pro is not already running. Here’s a detailed explanation and a possible solution:

Pyigor controls Igor Pro using a shell command IgorPro -Q -X COMMAND. This command is meant to execute the specified COMMAND in an already running instance of Igor Pro. In this case, the COMMAND is PyIgorLoadWave(). If Igor Pro is not running, this shell command starts Igor Pro as a subprocess. The call to subprocess.run([executable_path, "-Q", "-X", command]) in line 35 does not complete while the subprocess is running, which prevents the next command from being executed and causes the issue you reported. To avoid this problem, make sure Igor Pro is running before executing the Pyigor commands.

Additionally, a similar issue can occur if the Command key is held down while executing commands, as this also causes IgorPro -Q -X COMMAND to start a new process.

Please let me know if the issue continues.

— Reply to this email directly, view it on GitHubhttps://github.com/chocolate-icecream/pyigor/issues/3#issuecomment-2181086434, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGD7H4M7EKM4ZI4UO5VTNCTZIL6UPAVCNFSM6AAAAABJTVB6YSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBRGA4DMNBTGQ. You are receiving this because you authored the thread.Message ID: @.***>