Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45010

Re: Help with implementing callback functions using ctypes

From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Help with implementing callback functions using ctypes
Date 2013-05-09 08:57 +0200
References <8931a89c-0d00-4c8b-ba19-cf683d8d266d@googlegroups.com> <87mws4bsum.fsf@handshake.de>
Newsgroups comp.lang.python
Message-ID <mailman.1482.1368082690.3114.python-list@python.org> (permalink)

Show all headers | View raw


dieter, 09.05.2013 07:54:
> jamadagni writes:
>> ...
> I cannot help you with "ctypes". But, if you might be able to use
> "cython", then calling callbacks is not too difficult

+1 for using Cython. It also has (multi-)source level gdb support, which
greatly helps in debugging crashes like this one.

http://docs.cython.org/src/userguide/debugging.html


> (you can find an example in e.g. my "dm.xmlsec.binding").

An "official" example is here:

https://github.com/cython/cython/tree/master/Demos/callback


> Note, however, that properly handling the GIL ("Global Interpreter Lock")
> may be of great importance when the Python/C boundary is crossed --
> at least when you intend to use your code in a multi thread environment.

Cython makes this really easy. You can use the "with" statement to release
the GIL when you don't need it, and the compiler will produce errors when
you try to do things that require the GIL while you don't own it.

Stefan

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Help with implementing callback functions using ctypes jamadagni <samjnaa@gmail.com> - 2013-05-08 04:19 -0700
  Re: Help with implementing callback functions using ctypes dieter <dieter@handshake.de> - 2013-05-09 07:54 +0200
  Re: Help with implementing callback functions using ctypes Stefan Behnel <stefan_ml@behnel.de> - 2013-05-09 08:57 +0200
  Re: Help with implementing callback functions using ctypes Nobody <nobody@nowhere.com> - 2013-05-09 19:32 +0100
    Re: Help with implementing callback functions using ctypes jamadagni <samjnaa@gmail.com> - 2013-05-23 20:11 -0700
  Re: Help with implementing callback functions using ctypes Dan Stromberg <drsalists@gmail.com> - 2013-05-23 20:26 -0700
    Re: Help with implementing callback functions using ctypes Shriramana Sharma <samjnaa@gmail.com> - 2013-05-26 09:12 -0700
      RE: Help with implementing callback functions using ctypes Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-26 21:43 +0300
      Re: Help with implementing callback functions using ctypes Dan Stromberg <drsalists@gmail.com> - 2013-05-26 12:10 -0700

csiph-web