kuuko pushed a commit to branch master. http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=1ad70ef3d60dd3073b36edb1b04e0187608b17c7
commit 1ad70ef3d60dd3073b36edb1b04e0187608b17c7 Author: Kai Huuhko <[email protected]> Date: Fri Nov 29 23:41:07 2013 +0200 Utils.logger: Initialize threads in the module. If the print cb was called from another thread it would segfault. This was being triggered when Emotion printed out an error message. --- efl/utils/logger.pyx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/efl/utils/logger.pyx b/efl/utils/logger.pyx index cd27cc3..00dad98 100644 --- a/efl/utils/logger.pyx +++ b/efl/utils/logger.pyx @@ -33,6 +33,9 @@ cdef extern from "stdarg.h": cdef extern from "stdio.h": int vsprintf(char *, const_char *fmt, va_list args) +cdef extern from "Python.h": + void PyEval_InitThreads() + cdef tuple log_levels = ( 50, 40, @@ -45,18 +48,24 @@ cdef dict loggers = dict() cdef char log_buf[1024] -cdef void py_eina_log_print_cb(const_Eina_Log_Domain *d, - Eina_Log_Level level, - const_char *file, const_char *fnc, int line, - const_char *fmt, void *data, va_list args) with gil: + +PyEval_InitThreads() + +cdef void py_eina_log_print_cb(const_Eina_Log_Domain *d, Eina_Log_Level level, + const_char *file, const_char *fnc, int line, + const_char *fmt, void *data, va_list args) with gil: + cdef: - unicode msg - unicode name = d.name.decode("utf-8") + unicode msg, name + object rec, logger vsprintf(log_buf, fmt, args) + msg = log_buf.decode("utf-8") + name = d.name.decode("utf-8") - rec = logging.LogRecord(name, log_levels[level], file, line, msg, None, None, fnc) + rec = logging.LogRecord( + name, log_levels[level], file, line, msg, None, None, fnc) logger = loggers.get(name, loggers["efl"]) logger.handle(rec) --
