Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Know when an alert of photoshop is showing #181

Open
RichardLindhout opened this issue Aug 23, 2022 · 3 comments
Open

Know when an alert of photoshop is showing #181

RichardLindhout opened this issue Aug 23, 2022 · 3 comments

Comments

@RichardLindhout
Copy link

Describe the bug
Can I keep track of the alerts windows gives sometimes + close the alert and handle the error / skip the file

@loonghao
Copy link
Owner

@RichardLindhout

Could you please give me more context information?

@RichardLindhout
Copy link
Author

Sometimes windows give a blocking error e.g. file is in use or some other alert. I don't know how to get around these, it blocks the whole python code too
bf3AQ

@theaafofficial
Copy link

theaafofficial commented Mar 1, 2024

maybe late, One workaround is to use a timeout for stuck operations. In my case, photoshop crashes after a certain task and gets stuck on a crash report. Use asyncio's function wait_for
import asyncio


async def potentially_long_task():
    # Code that might take a while

async def my_endpoint():
    try:
        result = await asyncio.wait_for(potentially_long_task(), timeout=5)
        return result
    except asyncio.TimeoutError:
        return {"error": "Task took too long"} 

My use-case:

import subprocess
RETRIES = 2
for i in range(RETRIES):
    try:
        await asyncio.wait_for(
            your_photoshop_function_script(),
            timeout=60,
        )
        break
    except Exception as e:
        subprocess.call(["taskkill", "/F", "/IM", "Photoshop.exe"])
        logging.error(f"Error: {e}")
        if i < RETRIES - 1:
            logging.info(f"Retrying ...")
            continue
        else:
            logging.error(f"Failed to process {psd_path_abs}")
            raise

restarting photoshop works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants