5

I have a script that is constantly taking screenshots via PIL ImageGrab. Code looks like this:

def updateScreenshot(self):
        self.screen = ImageGrab.grab()

The updateScreenshot() function is called pretty often, like 2-3 times a second. The script was running fine until i refactored the class and moved all the screenshot related code to an external model class that encapsulates all the screenshot logic. Now my mainclass has:

self.screenshotService = ScreenshotService()

in it's __init__ function. The ScreenshotService then fires updateScreenshot(). The first few attempts of updateScreenshot() still work, after that the following error occurs:

File "...\screenshotService.py", line 15, in updateScreenshot
    self.screen = ImageGrab.grab()
  File "C:\Python34\lib\site-packages\PIL\ImageGrab.py", line 31, in grab
    size, data = grabber()

I found:

  1. https://github.com/python-pillow/Pillow/issues/1601
  2. Take a screenshot via a python script. [Linux]

but these dont really point me in the right direction.

Any ideas? Thanks.

Python 3.4, PIL: 5.4.1

BoA456
  • 341
  • 2
  • 15

0 Answers0