-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: '_thread._local' object has no attribute 'data' #261
Comments
Can you try again with the latest version (9.0.1 at the time)? |
It works if we adapt class Vision:
def __init__(self, mon):
self.mon = mon
def image_tracker(self, top, left, width, height, window_name):
with mss.mss() as sct:
mon = sct.monitors[self.mon]
coordinates = {'top': mon['top'] + top, 'left': mon['left'] + left, 'width': width, 'height': height}
while True:
img = np.asarray(sct.grab(coordinates))
cv2.imshow(f'{window_name}', img)
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break |
Traceback (most recent call last): ms = mss()
result with latest version |
without threads it work, but in thread, it doesn't work |
same error with this:
|
Please share the complete code. |
i tried to recreate error using easy example, but got another error: Exception in thread Thread-1 (scnd_trd):
this example fully shows what I need |
You can't use I reformated to be able to work on it more easily: import mss
import numpy as np
import threading
def scnd_trd():
class Name:
def __init__(self):
self.ms = mss.mss()
self.monitor = {'top': 100,'left': 100,'width': 20,'height': 20}
def func(self):
np.array(self.ms.grab(self.monitor))
def start(self) -> None:
self.func()
x = Name()
x.start()
s_t = threading.Thread(target=scnd_trd)
s_t.start() Here I moved the MSS instantiation into That would work for you? |
AttributeError: '_thread._local' object has no attribute 'srcdc' solved. There are 0 errors in the example. |
OK, I checked all the code of my program, the error was that the new system on the server returned null values for monitor
|
General information:
Description of the warning/error
just do steps like here: https://stackoverflow.com/questions/76298989/attributeerror-while-trying-to-use-threading-with-the-mss-library
but with mss.grab()
Full message
Other details
More information, if you think it is needed.
The text was updated successfully, but these errors were encountered: