Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify omc_process kill logic
... by dropping Python2 support
  • Loading branch information
ondras12345 committed Apr 17, 2025
commit 50b28982d691fd2c4ded9b19bdaace5eb4380f12
26 changes: 7 additions & 19 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,25 +391,13 @@ def __del__(self):
except Exception:
pass
self._omc_log_file.close()
if sys.version_info.major >= 3:
try:
self._omc_process.wait(timeout=2.0)
except Exception:
if self._omc_process:
self._omc_process.kill()
else:
for i in range(0, 100):
time.sleep(0.02)
if self._omc_process and (self._omc_process.poll() is not None):
break
# kill self._omc_process process if it is still running/exists
if self._omc_process is not None and self._omc_process.returncode is None:
logger.warning("OMC did not exit after being sent the quit() command; killing the process with pid=%s" % str(self._omc_process.pid))
if sys.platform == "win32":
self._omc_process.kill()
self._omc_process.wait()
else:
os.killpg(os.getpgid(self._omc_process.pid), signal.SIGTERM)
try:
self._omc_process.wait(timeout=2.0)
except Exception:
if self._omc_process:
print("OMC did not exit after being sent the quit() command; killing the process with pid={self._omc_process.pid}")
if sys.platform != "win32":
os.killpg(os.getpgid(self._omc_process.pid), signal.SIGTERM)
self._omc_process.kill()
self._omc_process.wait()

Expand Down