Half-slower stimuli displaying when changed working window

I use psychopy to display the visual stimuli on screen 2, and need to change the working window to my EEG recording software on screen 1.
When I do this, the stimuli displaying on screen 2 becomes about half slower.
the FPS of both monitor is 60Hz.

the major code is below:

grating = visual.GratingStim(win = win,…)

for i in range(180):

I hope the stimulus durations 3s but it dose about 6s.The grating moves slower and you can get a dissonant sensation

It works as my expectation when the dispalying window is the working window.

How can I solve this problem?