Bug 218652 - lang/python[27,35,36,*?]: thread issue in external library (both ctypes and C extension)
Summary: lang/python[27,35,36,*?]: thread issue in external library (both ctypes and C...
Status: Closed Feedback Timeout
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Only Me
Assignee: Walter Schwarzenfeld
URL: https://bugs.python.org/issue30069
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2017-04-14 10:11 UTC by Sylvain Garrigues
Modified: 2019-09-03 02:29 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (python)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Garrigues 2017-04-14 10:11:44 UTC
Hello, 

I have libsylvain.so which has just one function (sylvain_display()) which displays an hello world windows through QT libraries.

I have this one program `sylvain' which is a single line program which calls sylvain_display from libsylvain.so.

When I run `sylvain', I have some debug output from QT on the console, and the hello world window is displayed on my TV (I am running this on a Raspberry Pi with FreeBSD).

Now, when I run python2.7 or python3.6, and load libsylvain.so either through the ctypes module or through a C extension module, and call the sylvain_display() function from python, I have the console log output from QT as with the `sylvain' program, but I don't have the window on my TV!

I guess the rendering to the TV is done on a separate thread and this one is not called or locked?

I came up with this simple test program to isolate the issue because both PyQT and PySide now don't work as expected, I have console log but no actual TV output.

This used to work one year ago, I don't know what has changed in Python. 

Hope you guys will figure this out.

libsylvain.cpp: http://dev.sylvaingarrigues.com/libsylvain.cpp
sylvain.cpp (test program for libsylvain): http://dev.sylvaingarrigues.com/sylvain.cpp 
sylvain-ctypes.py (load libsylvain): http://dev.sylvaingarrigues.com/sylvain-ctypes.py

Also tried with a C extension to rule out ctypes bug, same issue:
sylvainmodule.cpp (python module wrapper): http://dev.sylvaingarrigues.com/sylvainmodule.cpp
sylvain-next.pu (load sylvainmodule and sylvain_display): http://dev.sylvaingarrigues.com/sylvain-cext.py

build script: http://dev.sylvaingarrigues.com/build.sh
Comment 1 Sylvain Garrigues 2017-04-14 10:13:57 UTC
libsylvain and sylvain and python3.6 on MacOS work (the hello world window is always displayed when loading libsylvain), so this is FreeBSD's python specific.
Comment 2 Sylvain Garrigues 2017-04-14 10:16:34 UTC
I have reproduced this issue in python2.7, python3.5 and python3.6.
Comment 3 Eir Nym 2018-09-29 11:34:01 UTC
To do so you need to Ä…dd better thread synchronisation in Python <-> QT communication. If you'd build a whole QT program inside Python using PyQT, all work has been done for you already.

Threading model in various platforms and OSes are slightly different and without proper manual synchronization, you'd probably get different results.
Comment 4 Walter Schwarzenfeld freebsd_triage 2019-09-02 10:51:15 UTC
Seems solved:
https://bugreports.qt.io/browse/QTBUG-60260

It is also am feedback timeout. I close it with this status. If there are still problems, please re-open.
Comment 5 Kubilay Kocak freebsd_committer freebsd_triage 2019-09-03 02:29:53 UTC
^Triage: Leave python@ (or other freebsd teams/groups, previous Assignee:) as a CC when Assigning to oneself and closing issues !FIXED