Skip to content
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

Stuck with lock.py #1

Open
arnoldmitrica opened this issue Mar 25, 2020 · 1 comment
Open

Stuck with lock.py #1

arnoldmitrica opened this issue Mar 25, 2020 · 1 comment

Comments

@arnoldmitrica
Copy link

First, thank you for your tutorial from yt. Really nice done.

After I load the script using python lock.py it says:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "lock.py", line 195, in listen_rfid
rfid_presented += keys[ event.code ]
IndexError: string index out of range

Exception TypeError: TypeError('super() takes at least 1 argument (0 given)',) in <bound method InputDevice.del of InputDevice('/dev/input/event0')> ignored

-------------------------------------For line 801 in threading.py----------------------------------

def __bootstrap_inner(self):

    try:
        self._set_ident()
        self.__started.set()
        with _active_limbo_lock:
            _active[self.__ident] = self
            del _limbo[self]
        if __debug__:
            self._note("%s.__bootstrap(): thread started", self)

        if _trace_hook:
            self._note("%s.__bootstrap(): registering trace hook", self)
            _sys.settrace(_trace_hook)
        if _profile_hook:
            self._note("%s.__bootstrap(): registering profile hook", self)
            _sys.setprofile(_profile_hook)

try:
self.run() LINE 801

        except SystemExit:
            if __debug__:
                self._note("%s.__bootstrap(): raised SystemExit", self)
        except:
            if __debug__:
                self._note("%s.__bootstrap(): unhandled exception", self)
            # If sys.stderr is no more (most likely from interpreter
            # shutdown) use self.__stderr.  Otherwise still use sys (as in
            # _sys) in case sys.stderr was redefined since the creation of
            # self.
            if _sys and _sys.stderr is not None:
                print>>_sys.stderr, ("Exception in thread %s:\n%s" %
                                     (self.name, _format_exc()))
            elif self.__stderr is not None:
                # Do the best job possible w/o a huge amt. of code to
                # approximate a traceback (code ideas from
                # Lib/traceback.py)
                exc_type, exc_value, exc_tb = self.__exc_info()
                try:
                    print>>self.__stderr, (
                        "Exception in thread " + self.name +
                        " (most likely raised during interpreter shutdown):")
                    print>>self.__stderr, (
                        "Traceback (most recent call last):")
                    while exc_tb:
                        print>>self.__stderr, (
                            '  File "%s", line %s, in %s' %
                            (exc_tb.tb_frame.f_code.co_filename,
                                exc_tb.tb_lineno,
                                exc_tb.tb_frame.f_code.co_name))
                        exc_tb = exc_tb.tb_next
                    print>>self.__stderr, ("%s: %s" % (exc_type, exc_value))
                # Make sure that exc_tb gets deleted since it is a memory
                # hog; deleting everything else is just for thoroughness
                finally:
                    del exc_type, exc_value, exc_tb
        else:
            if __debug__:
                self._note("%s.__bootstrap(): normal return", self)
        finally:
            # Prevent a race in
            # test_threading.test_no_refcycle_through_target when
            # the exception keeps the target alive past when we
            # assert that it's dead.
            self.__exc_clear()
    finally:
        with _active_limbo_lock:
            self.__stop()
            try:
                # We don't call self.__delete() because it also
                # grabs _active_limbo_lock.
                del _active[_get_ident()]
            except:
                pass

---------------------------------------For line 754 in threading.py ------------------------------

def run(self):

    """Method representing the thread's activity.

    You may override this method in a subclass. The standard run() method
    invokes the callable object passed to the object's constructor as the
    target argument, if any, with sequential and keyword arguments taken
    from the args and kwargs arguments, respectively.

    """
    try:
        if self.__target:

self.__target(*self.__args, **self.__kwargs) LINE 754

    finally:
        # Avoid a refcycle if the thread is running a function with
        # an argument that has a member that points to the thread.
        del self.__target, self.__args, self.__kwargs
@bixicy
Copy link

bixicy commented May 4, 2020

Yes, the 0-argument syntax is specific to Python 3.

In Python 2 and code that must be cross-version compatible, just stick to passing in the class object and instance explicitly.

And by the way, Python 2 has reached End Of Life. Try to change to Python 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants