Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Windows: fix multi-thread unsafe and update test #159
Conversation
On Windows, the handle of entire window device context is saved to `srcdc`. But the device context will be released once the thread who creates it has died, so that `srcdc` is no loner valid. Replace `srcdc` with `srcdc_dict` to maintain srcdc values created by multiple threads which ensure the validity of srcdc when it's used. A threading lock is add to prevent multiple threads from grabbing and modifying shared class attributes `bmp`/`srcdc`/`memdc` (their windows object in fact) at same time. Otherwise, unexpected screenshot or unpredictable error will occur. Add test_thread_safety in test_windows.py Closes #150
|
Thanks a lot @narumishi :) |
|
Sorry @BoboTiG , I have forgotten to remove the wrong comment If one second per loop, the exception caused by resouces written by multiple threads at same time will occur at a very low possibility. So I removed |
|
OK thanks :) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Changes proposed in this PR
srcdcwithsrcdc_dictto maintain srcdc values created by multiple threadsMSS._lockto ensure multi-thread safeIt is very important to keep up to date tests and documentation.
Is your code right?
flake8passed