NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future

Question:

I am writing a Python program with two threads. One displays a GUI and the other gets input from a scanner and saves data in an online database. The code works fine on my raspberry pi but if I try it on my MacBook Pro (Catalina 10.15.2), I get the above mentioned warning followed by my code crashing.

Does anyone have an idea how to get it working or what causes the problem?

Asked By: Nothing

||

Answers:

You likely use different Python versions. Your Python on your Raspberry PI still allows invalidating NSWindow drag regions outside the Main thread, while your Python in your MacBook Pro already stopped supporting this. You will likely need to refactor your code so that NSWindow drag regions will only be invalidated on the Main thread.

You need to localize where NSWindow drag regions are invalidated and make sure that those happen in the Main thread.

EDIT

The asker explained that according to his/her findings, NSWindow drag regions only apply to Mac.

Answered By: Lajos Arpad

You might want to call:

matplotlib.pyplot.switch_backend('Agg') 
  • so that your server does not try to create (and then destroy) GUI windows that will never be seen.
Answered By: Daniel Moraite