On Mon, Feb 25, 2019 at 1:56 AM Randall O'Reilly <rcoreil...@gmail.com>
wrote:
> I’m building a shared library of Go code that is loaded as a module by
> python, and called from there.  Somehow, I need to ensure that one
> particular function is called on the main thread (Mac OS cocoa gui event
> loop code requires this).  I tried adding an init() function in the library
> and called runtime.LockOSThread() there, but that didn’t work (docs say it
> should, but presumably that doesn’t apply to the dynamic lib situation).
> Thanks,
>

You have to ensure you only call the function from the python main thread.
See
https://stackoverflow.com/questions/23206787/check-if-current-thread-is-main-thread-in-python
for how to do that. Using LockOSThread() only works if you call your Go
service loop function from the python main thread. You can't use it to
force your Go function to run on the main thread when called from a
non-main thread.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to