itom-project/itom

[Linux/raspi] python threading not working

photoniker opened this issue · 0 comments

following snippet works when issued without itom but breaks itom when run within it…

def bla():
  print("bla")
import threading
t=threading.Thread(target=bla)
t.start()

I verified python to be same executable:

import sys
print(sys.executable)

prints

/usr/bin/python3

Errormessage from crashed itom is

libgcc_s.so.1 must be installed for pthread_cancel to work

Can you reproduce this on another pi?

[Issue created by Oliver Schwanke: 2020-10-12]
[Last updated on bitbucket: 2020-10-16]

[Comment created by Oliver Schwanke: 2020-10-16]
see answer before.
Solution found, unrelated to itom,

[Comment created by Oliver Schwanke: 2020-10-16]
As always - thank you so much for your help!

I found this to be unrelated to itom actually, but to be some knoen issue with python multithreading,

with libgcc_s_so.1 to be unloaded to early.

A somewhat hacky solution is to make sure this dll does not get unloaded, so adding

import ctypes
libgcc_s = ctypes.CDLL("libgcc_s.so.1")

and making sure this variable does not get deleted, before the thread has finished solves the error.

Check this launchpad thread…

I am closing this and leaving it here for self reference…

[Comment created by M. Gronle: 2020-10-12]
I also have python under user/bin/python3.

For me your example works and I get the bla print out in the command line.
I have a Raspberry Pi 4B with the newest Raspbian (based on Debian Buster).

However if have the library libgcc_s.so.1 installed under /lib/arm-linux-gnueabihf/libgcc_s.so.1.

Please tell me if I can make further tests with my device.