runtime/xenomai.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 27 Jun 2018 13:57:03 +0300
changeset 2233 32445e3c9cfc
parent 2015 4eeefc6a13fd
child 3750 f62625418bff
permissions -rw-r--r--
Catch 'clipboard already open' errors in editors

Apparently following commits have not fixed the problem completely,
because it still happens (although not so often).

changeset: 2019:b8f795bdfe9f
user: Andrey Skvortsov <andrej.skvortzov@gmail.com>
date: Fri May 25 17:40:29 2018 +0300
summary: fix hangs on mouse selection in case if wxPython uses wxWidgets with GTK3+ support

changeset: 2018:5ce6d08ff2c7
user: Andrey Skvortsov <andrej.skvortzov@gmail.com>
date: Fri May 25 17:23:15 2018 +0300
summary: make clipboard open minimal time as wxPython documentation recommends
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# See COPYING.Runtime file for copyrights details.
#

from __future__ import absolute_import
from ctypes import CDLL, RTLD_GLOBAL, pointer, c_int, POINTER, c_char, create_string_buffer


def TryPreloadXenomai():
    """
    Xenomai 3 (at least for version <= 3.0.6) do not handle properly dlclose
    of shared objects whose dlopen did trigger xenomai_init.
    As a workaround, this pre-loads xenomai libraries that need to be
    initialized and call xenomai_init once for all.

    Xenomai auto init of libs MUST be disabled (see --auto-init-solib in xeno-config)
    """
    try:
        for name in ["cobalt", "modechk", "copperplate", "alchemy"]:
            globals()[name] = CDLL("lib"+name+".so", mode=RTLD_GLOBAL)
        cobalt.xenomai_init(pointer(c_int(0)), pointer((POINTER(c_char)*2)(create_string_buffer("prog_name"), None)))
    except Exception:
        pass