A .py script to 100% boot Photoshop CC 2019 using all CPU

Questions about Wine on Linux
Locked
artik
Level 2
Level 2
Posts: 11
Joined: Sun Mar 15, 2015 6:32 am

A .py script to 100% boot Photoshop CC 2019 using all CPU

Post by artik »

As Photoshop CC 2019 in now fully working (using this method: https://appdb.winehq.org/objectManager. ... &iId=37541), a friend of mine wrote me a little Python 3 script to get a 100% boot rate.

Using the "taskset" method only allows you to use 1 processor. This script will boot you PS CC 2019 with all CPUs working.

What does it do: The script will read and identity the CC 2019 boot process. If failure lines are found, kills the .exe and relaunch it. Another state doesn't return any errors, just a standy of the boot process. In this case the script start a countdown of 3 seconds to monitor if the process continues to boot. If not, kills the .exe and start it again.

Photoshop will 100% boot using the script. Your PS CC path (line 21) must be adapted to your configuration. The script can also be adapted to Photoshop CS 6. Enjoy it, and feel free to update it or make it better.

Code: Select all

#!/usr/bin/env python3

import subprocess, re, sys, signal

error_keywords = re.compile('^.*(Assertion|0x65372a0).*$')
success_keywords = re.compile('^.*(list_manager_QueryInterface).*$')

exited = False
process = None
successful_launch = False
timeout = 3

def kill_photoshop(signalnum, frame):
	if not successful_launch:
		print("No successful launch withing %d seconds, killing photoshop ..."%timeout, file=sys.stderr)
		process.kill()

signal.signal(signal.SIGALRM, kill_photoshop)

while not exited:
	process = subprocess.Popen(["wine64", "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe"], stderr=subprocess.PIPE)
	successful_launch = False
	signal.alarm(timeout)
	while True:
		if process.poll():
			break
		line = process.stderr.readline()
		# print("got line %d and process %s"%(len(line),process.poll()))
		if len(line) == 0 and process.poll() is not None:
			if process.poll() == 0:
				exited = True
			break
		if line:
			print(line.strip())
			if success_keywords.match(str(line)):
				print("Successful photoshop launch detected", file=sys.stderr)
				successful_launch = True
			if error_keywords.match(str(line)):
				print("Error keyword match, killing process", file=sys.stderr)
				process.kill()
				break
	print("Process return code %d"%process.wait())
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: A .py script to 100% boot Photoshop CC 2019 using all CP

Post by DarkShadow44 »

That will get lost here, I guess you could post it in an appdb report though.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: A .py script to 100% boot Photoshop CC 2019 using all CP

Post by Bob Wya »

artik wrote:...
Photoshop will 100% boot using the script. Your PS CC path (line 21) must be adapted to your configuration. The script can also be adapted to Photoshop CS 6. Enjoy it, and feel free to update it or make it better.
...
I've added the script, as a Wiki Note, to the Photoshop CC 2109 WineHQ AppDB page.
I'm pretty sure it's correct (I fixed a couple of minor items) but you might want to double check!

I've also linked the CC 2019 version of Photoshop against the bug you've (/ your friend) worked around:
Bug 35041 - Multiple apps and games crash with heap corruption or live-lock in libX11 (EA Origin, Garmin Express Fit, SMPlayer, LotRO launcher, Kindle for PC, Conan Exiles)('taskset -c 0 wine ./foo.exe' is a workaround)

Bob
artik
Level 2
Level 2
Posts: 11
Joined: Sun Mar 15, 2015 6:32 am

Re: A .py script to 100% boot Photoshop CC 2019 using all CP

Post by artik »

Little improvement, added the wine setting:

Code: Select all

__GL_MaxFramesAllowed="1"
to fix the one frame delay with Nvidia cards. Does the "HowTo / Notes" can be updated ?
https://appdb.winehq.org/objectManager. ... &iId=37541

Thanks

Code: Select all

#!/usr/bin/env python3

import subprocess, re, sys, signal, os

error_keywords = re.compile('^.*(Assertion|0x65372a0).*$')
success_keywords = re.compile('^.*(list_manager_QueryInterface).*$')
os.environ['__GL_MaxFramesAllowed'] = "1"

exited = False
process = None
successful_launch = False
timeout = 3

def kill_photoshop(signalnum, frame):
	if not successful_launch:
		print("No successful launch withing %d seconds, killing photoshop ..."%timeout, file=sys.stderr)
		process.kill()

signal.signal(signal.SIGALRM, kill_photoshop)

while not exited:
	process = subprocess.Popen(["wine64", "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe"], env=os.environ, stderr=subprocess.PIPE)
	successful_launch = False
	signal.alarm(timeout)
	while True:
		if process.poll():
			break
		line = process.stderr.readline()
		# print("got line %d and process %s"%(len(line),process.poll()))
		if len(line) == 0 and process.poll() is not None:
			if process.poll() == 0:
				exited = True
			break
		if line:
			print(line.strip())
			if success_keywords.match(str(line)):
				print("Successful photoshop launch detected", file=sys.stderr)
				successful_launch = True
			if error_keywords.match(str(line)):
				print("Error keyword match, killing process", file=sys.stderr)
				process.kill()
				break
	print("Process return code %d"%process.wait())
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: A .py script to 100% boot Photoshop CC 2019 using all CP

Post by Bob Wya »

artik wrote:Little improvement, added the wine setting:

Code: Select all

__GL_MaxFramesAllowed="1"
to fix the one frame delay with Nvidia cards. Does the "HowTo / Notes" can be updated ?
https://appdb.winehq.org/objectManager. ... &iId=37541

Thanks

...
Rigtheo, tis done. 8)

Bob
bluehat
Newbie
Newbie
Posts: 1
Joined: Wed Feb 19, 2020 9:44 am

Re: A .py script to 100% boot Photoshop CC 2019 using all CPU

Post by bluehat »

artik wrote: Thu Jun 13, 2019 5:45 am As Photoshop CC 2019 in now fully working (using this method: https://appdb.winehq.org/objectManager. ... &iId=37541), a friend of mine wrote me a little Python 3 script to get a 100% boot rate.

Using the "taskset" method only allows you to use 1 processor. This script will boot you PS CC 2019 with all CPUs working.

What does it do: The script will read and identity the CC 2019 boot process. If failure lines are found, kills the .exe and relaunch it. Another state doesn't return any errors, just a standy of the boot process. In this case the script start a countdown of 3 seconds to monitor if the process continues to boot. If not, kills the .exe and start it again.

Photoshop will 100% boot using the script. Your PS CC path (line 21) must be adapted to your configuration. The script can also be adapted to Photoshop CS 6. Enjoy it, and feel free to update it or make it better.

Code: Select all

#!/usr/bin/env python3

import subprocess, re, sys, signal

error_keywords = re.compile('^.*(Assertion|0x65372a0).*$')
success_keywords = re.compile('^.*(list_manager_QueryInterface).*$')

exited = False
process = None
successful_launch = False
timeout = 3

def kill_photoshop(signalnum, frame):
	if not successful_launch:
		print("No successful launch withing %d seconds, killing photoshop ..."%timeout, file=sys.stderr)
		process.kill()

signal.signal(signal.SIGALRM, kill_photoshop)

while not exited:
	process = subprocess.Popen(["wine64", "/home/artik/.wine/drive_c/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe"], stderr=subprocess.PIPE)
	successful_launch = False
	signal.alarm(timeout)
	while True:
		if process.poll():
			break
		line = process.stderr.readline()
		# print("got line %d and process %s"%(len(line),process.poll()))
		if len(line) == 0 and process.poll() is not None:
			if process.poll() == 0:
				exited = True
			break
		if line:
			print(line.strip())
			if success_keywords.match(str(line)):
				print("Successful photoshop launch detected", file=sys.stderr)
				successful_launch = True
			if error_keywords.match(str(line)):
				print("Error keyword match, killing process", file=sys.stderr)
				process.kill()
				break
	print("Process return code %d"%process.wait())
Locked