pthread kill - Python edition

I have a tiny little helper app in Python - 10 lines of code calling into a library. I’m doing final testing of the 64bit version of my app and see what I found:

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff769d29a6 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff76a70000 pthread_kill + 285
2 libsystem_c.dylib 0x00007fff7692509d abort + 127
3 org.python.python 0x0000000100626f71 Py_FatalError + 65
4 org.python.python 0x0000000100628d23 _Py_InitializeEx_Private + 1379
5 com.mothsoftware.fix_encoding 0x0000000100002a1f 0x100000000 + 10783
6 com.mothsoftware.fix_encoding 0x0000000100000f7d main + 333
7 com.mothsoftware.fix_encoding 0x0000000100000e04 start + 52

That looks like the mails I get from Feedback every couple of days.

There isn’t even a thread. Perhaps there is one in the library I’m calling but I doubt it. At least this made me laugh.

How are you calling out to the Python code?

The code lives in a compiled Python app which I call with the shell:

[code]dim PathToPython as FolderItem = App.ExecutableFile
if PathToPython <> nil and PathToPython.Exists then PathToPython = PathToPython.Parent.Parent
if PathToPython <> nil and PathToPython.Exists then PathToPython = PathToPython.Child(“Resources”)
if PathToPython <> nil and PathToPython.Exists then PathToPython = PathToPython.Child(“fix_encoding.app”)
if PathToPython <> nil and PathToPython.Exists then PathToPython = PathToPython.Child(“Contents”)
if PathToPython <> nil and PathToPython.Exists then PathToPython = PathToPython.Child(“MacOS”)
if PathToPython <> nil and PathToPython.Exists then PathToPython = PathToPython.Child(“fix_encoding”)
if PathToPython = Nil or not PathToPython.Exists then Return

dim tempFile as FolderItem = GetTemporaryFolderItem
try
dim binStream as BinaryStream = BinaryStream.Create(tempFile, True)
binStream.Write(currentBody)
binStream.Close
catch err as IOException
Return
end try

dim PythonShell as new Shell
PythonShell.Mode = 0
PythonShell.Execute(PathToPython.ShellPath + " " + tempFile.ShellPath)
if PythonShell.ErrorCode = 0 then currentBody = PythonShell.Result[/code]

Are you actually including a python environment within your app? Here’s what I would do:

theShell.execute "which python" If theShell.ErrorCode <> 0 Then MsgBox "Python interpreter not found" quit Else pyPath = NthfieldB(theShell.ReadAll, EndOfLine, 1) End If theShell.execute """" + pyPath + """ """ + tempFile.NativePath if PythonShell.ErrorCode = 0 then currentBody = PythonShell.Result

I’m using py2app to make a full app with Python 3.6 in the app.

i can follow that, but since the Python module is part of your app and not standalone (I’m guessing), why bloat your app when 95% of all system have a python interpreter on board. I have my python code in 64 bit encoded strings and I write them out to temp files and then call the onboard Python interpreter as above.

I’m also looking at the Python module in the Einhugur suite to just handle the code internally.