0

I'm trying to declare an object of a class that is defined in a local .py-file that I have not written myself. The declaration goes like this:

GPS_thread = GPS()
GPS_thread.run()

When it reaches the second line the program crashes and gives the error "AttributeError:_Thread__target". I have no idea what this means.

I have tried to look up other forum threads on similar subjects and found that they often recomend that I try to look for a local file called "threading" which is blocking the view of the proper file. The only thing I could fins was threading.pyc, the compiled version of threading.py, which is imported in the GPS-library. I deleted it, but that did not help.

Any advice?

Traceback (most recent call last):
  File "C:\Users\Python\mscript\controlc.py", line 228, in <module>
    main()
  File "C:\Users\Python\mscript\controlc.py", line 140, in main
    GPS_thread.run()
  File "C:\Python27\lib\threading.py", line 767, in run
    del self.__target, self.__args, self.__kwargs
AttributeError: _Thread__target
2
  • Can you post the full traceback (all of the error message). Commented Jul 15, 2014 at 8:32
  • GPS - Global Positioning System. I'm working with a project that uses GPS-devices. The code controling them is in a particular, locally written library. Commented Jul 15, 2014 at 8:38

1 Answer 1

4

run is what you override, but don't call: docs.
Use GPS_thread.start(), this will fork and call GPS_thread.run in the background. docs

Sign up to request clarification or add additional context in comments.

1 Comment

The __init__(self) of the GPS-class calls the start()-method, which I guess then calls the (locally defined) run()-method. Manually calling the run()-method apparently was a misguided attempt to solve another problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.