Home > OS >  A simple python script I wrote has threads?
A simple python script I wrote has threads?

Time:05-05

I am currently studying operating systems in college. This has made me more aware of what's going on in my macOS's Activity Monitor. Yesterday, I wrote a simple python program that has a 3 window GUI (using pysimplegui), and when I check on it in Activity Monitor, I see that sometimes it has between 4-7 threads. I did not use threading at all, and, according to what I learned, a single threaded program should only show 1 thread.

activity monitor

Please help me understand what's going on.

CodePudding user response:

I haven't used pyaimplegui before, but it is very common for the libraries to use threads without you knowing it. For example, guis use threads to give you the ability to move the window around when some type of expensive computation is happening in the background; instead of freezing the entire window.

You can try to read the documentation for the library to see if/how they are using threads.

Side note: Also, you need to be aware that threading in Python is not similar to threading in other languages due to the GIL/mutex.

  • Related