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

If the clipboard fails to open on Windows, wait and try again #7141

Merged
merged 1 commit into from Jun 6, 2023

Conversation

radarhere
Copy link
Member

Resolves #7133

The user is intermittently hitting

Pillow/src/display.c

Lines 439 to 440 in 2467db4

if (!OpenClipboard(NULL)) {
PyErr_SetString(PyExc_OSError, "failed to open clipboard");

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-openclipboard states

OpenClipboard fails if another window has the clipboard open.

If the error is hit, this PR pauses for 0.5s, and then tries again.

@siteng98
Copy link

I think this would work great!

@hugovk hugovk merged commit 3568df8 into python-pillow:main Jun 6, 2023
60 checks passed
@radarhere radarhere deleted the grabclipboardwin32 branch June 6, 2023 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImageGrab gives OSError randomly
3 participants