1 year ago

#302688

test-img

Brandon S

Mutex Destroy Failing on RP4 Port

Wed Mar 16, 2022 9:43 pm

Hi, I am relatively new to the Raspberry Pi and have been trying to port some Python source code originally compiled for Windows to a Pi 4. I was able to port everything over save for Win32API, I ended up commenting out "import win32api".

The python code runs until the last error handling statement and I believe it has to do with win32api. Whenever I run this code, I get the error "python3:../../libusb/os/threads_posix.h:58: usbi_mutex_destroy: Assertion `pthread_mutex_destroy(mutex) == 0' failed."

The bit of code that I've traced it to is:

if __name__ == '__main__':
    # vp_start_gui()
    # find_usb_port()
    root = tk.Tk()

    prog_call = sys.argv[0]
    prog_location = os.path.split(prog_call)[0]
    define.APP_LOCATION = prog_location
    file_location = os.path.join(prog_location, "./project_loc.txt")

    # Get project folder path
    f = open(file_location, 'r')
    file_loc = f.read().replace('\n', '').strip()
    f.close()
    define.ASSAY_FOLDER_PATH = str(file_loc)
    # print("define.ASSAY_FOLDER_PATH11: ", define.ASSAY_FOLDER_PATH)

    try:
        while define.ASSAY_FOLDER_PATH == "":
            define.LOAD_ASSAY_FILE = True
            resp = tkinter.messagebox.askokcancel('Select Directory for Assay files: ',
                                                  "Select a directory for Assay files and log files")

            if resp is True:
                define.ASSAY_FOLDER_PATH = filedialog.askdirectory(title='Select a directory for INT05 Project')
            else:
                root.destroy()
                sys.exit()

            # Save the log folder file to log_loc.txt to save logs
            f = open(file_location, 'w')
            f.writelines(str(define.ASSAY_FOLDER_PATH))
            f.close()
            # debug_print("define.ASSAY_FOLDER_PATH: ", define.ASSAY_FOLDER_PATH)

        client = ThreadedClient(root)
        root.mainloop()
    except Exception as e:
        # debug_print(e)
        messagebox.showerror("ERROR", "Run the app with administrative privilege... "
                                      "(This has to be done on very first run!")
        sys.exit()

When run, the GUI pops up with the "ERROR", "Run the app with administrative privilege..." statement regardless if I run the code as root.

Any ideas on what I am doing wrong or how to get around this error would be greatly appreciated! I've been spinning my wheels on this for awhile now.

Thanks!

python

winapi

raspberry-pi

tinker

0 Answers

Your Answer

Accepted video resources