From 47b41806510aec64480833b8cf18bae7fb0beb9d Mon Sep 17 00:00:00 2001 From: Henrik Tunedal Date: Thu, 25 Apr 2024 22:26:09 +0200 Subject: [PATCH] gh-118293: Suppress mouse cursor change in multiprocessing --- Lib/multiprocessing/popen_spawn_win32.py | 5 ++++- .../Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst diff --git a/Lib/multiprocessing/popen_spawn_win32.py b/Lib/multiprocessing/popen_spawn_win32.py index 49d4c7eea224111..63a74c92378b73e 100644 --- a/Lib/multiprocessing/popen_spawn_win32.py +++ b/Lib/multiprocessing/popen_spawn_win32.py @@ -3,6 +3,7 @@ import signal import sys import _winapi +from subprocess import STARTUPINFO from .context import reduction, get_spawning_popen, set_spawning_popen from . import spawn @@ -18,6 +19,7 @@ TERMINATE = 0x10000 WINEXE = (sys.platform == 'win32' and getattr(sys, 'frozen', False)) WINSERVICE = sys.executable.lower().endswith("pythonservice.exe") +STARTF_FORCEOFFFEEDBACK = 0x80 def _path_eq(p1, p2): @@ -74,7 +76,8 @@ def __init__(self, process_obj): try: hp, ht, pid, tid = _winapi.CreateProcess( python_exe, cmd, - None, None, False, 0, env, None, None) + None, None, False, 0, env, None, + STARTUPINFO(dwFlags=STARTF_FORCEOFFFEEDBACK)) _winapi.CloseHandle(ht) except: _winapi.CloseHandle(rhandle) diff --git a/Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst b/Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst new file mode 100644 index 000000000000000..087ac01fc7bdec4 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst @@ -0,0 +1,2 @@ +The `multiprocessing` module now passes the `STARTF_FORCEOFFFEEDBACK` flag +when spawning processes to tell Windows not to change the mouse cursor.