Python parallelization (multiprocessing) BrokenPipe with telnet

43 Views Asked by At

I am writing a script with GUI to control a device (DDS). The DDS is controlled with telnet and because of timing issues I run it in a separate process. The script connects to the device, but when trying to set the frequency output I get the Errno 32 Broken pipe BrokenPipeError.

I double-checked the connection using Telnet via the terminal and by running only the part of the code responsible for the connection (which is then in the main process). In both cases everything runs smoothly and I get no errors. Problem happens when I run the full script with GUI and the telnet connection happens in a separate process. Here is the output:

DDS connected!
Process Process-1:
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/local/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/jakubdobosz/Library/CloudStorage/[email protected]/Mój dysk/github/FrequencyDriftStabilizer/gui.py", line 46, in _handleStab
    handler.filterUpdate()
  File "/Users/jakubdobosz/Library/CloudStorage/[email protected]/Mój dysk/github/FrequencyDriftStabilizer/src/handlerStabilization.py", line 155, in filterUpdate
    self._DDS.setFreq(self._DDSfreq)
  File "/Users/jakubdobosz/Library/CloudStorage/[email protected]/Mój dysk/github/FrequencyDriftStabilizer/src/DDS_AD9912.py", line 91, in setFreq
    self._DDS.write(cmd.encode('UTF-8'))
  File "/usr/local/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/telnetlib.py", line 292, in write
    self.sock.sendall(buffer)
BrokenPipeError: [Errno 32] Broken pipe

Is there a way to communicate with the device through telnet in a subprocess? Or maybe there is another problem, not the one I assumed.

0

There are 0 best solutions below