# OpenCV update breaks waitKey behaviour

**URL:** <https://forum.opencv.org/t/opencv-update-breaks-waitkey-behaviour/20251>\
**Category:** Uncategorized\
**Tags:** highgui, flask\
**Created:** [February 17, 2025, 10:37am UTC](https://forum.opencv.org/t/opencv-update-breaks-waitkey-behaviour/20251 "2025-02-17T10:37:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gophys](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/gophys/32/12042_2.png) [@Gophys](https://forum.opencv.org/u/Gophys)\
**Post date:** [February 17, 2025, 10:37am UTC](https://forum.opencv.org/t/opencv-update-breaks-waitkey-behaviour/20251/1 "2025-02-17T10:37:53Z")

</div>

I took back a python project that uses openCV to show images in a separate window. The project is in python 3.8 and I am upgrading it to python 3.12. I also updating openCV from version 4.4.0.46 to version 4.11.0.86.  
The project consist of a local web server with Flask that can do various operations depending on the API call.

One API call result in the following set of lines of code:

```auto
   window_name = "projector"
   if cv2.getWindowProperty(window_name, 0) >= 0:
            cv2.imshow(window_name, full_screen_frame)
   else:
            cv2.namedWindow(window_name, cv2.WND_PROP_FULLSCREEN)
            cv2.moveWindow(window_name, window_move[0], window_move[1])
            cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)

            cv2.imshow(window_name, full_screen_frame)
            cv2.waitKey()

```

In the 4.4 version, I can call this API multiple times and everything works fine.  
In the 4.11 version I have an exception on the getWindowProperty call. I fixed it using a try/except clause and the image shows just fine. But when the API il called again, the code stop executing a the getWindowProperty line, as if the waitKey is blocking the execution.

I have another API that closes the window with cv2.destroyAllWindows() but it also frezze on that line with the version 4.11

I don’t understand this change of behaviour. Do you know how to solve this issue ?  
Thank you

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [February 17, 2025, 4:01pm UTC](https://forum.opencv.org/t/opencv-update-breaks-waitkey-behaviour/20251/2 "2025-02-17T16:01:44Z")

</div>

flask is for making web servers/services.

you cannot mix that with desktop GUI.

the lifecycles don’t mesh. each has its own lifecycle/event loop. you’d have to know not just how each does its event looping, but you’d also have to know if any of those involves threading, and if the other would tolerate such threading.

if any GUI provided by OpenCV _used to_ work in a **flask loop** , then that worked outside of spec.

you could try to use a proper GUI toolkit, from within your flask lifecycle, e.g. Tkinter, Qt, GTK, WX, OpenGL/imgui, …
