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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'interpreter': 0.05; 'compiler': 0.07; 'debugging': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:using': 0.09; 'url:github': 0.09; 'subject:Help': 0.11; 'thread': 0.14; '"official"': 0.16; '"with"': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'python/c': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:ctypes': 0.16; '(you': 0.16; 'properly': 0.19; 'stefan': 0.19; 'example': 0.22; 'header :User-Agent:1': 0.23; 'handling': 0.26; 'least': 0.26; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'errors': 0.30; 'statement': 0.30; 'code': 0.31; 'boundary': 0.31; 'writes:': 0.31; 'subject:with': 0.35; 'received:84': 0.35; 'really': 0.36; 'url:org': 0.36; 'too': 0.37; 'level': 0.37; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'environment.': 0.39; 'support,': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'release': 0.40; 'helps': 0.61; 'here:': 0.62; 'great': 0.65; 'received:arcor-ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84; 'url:master': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Help with implementing callback functions using ctypes
Date Thu, 09 May 2013 08:57:55 +0200
References <8931a89c-0d00-4c8b-ba19-cf683d8d266d@googlegroups.com> <87mws4bsum.fsf@handshake.de>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host dslb-084-056-052-005.pools.arcor-ip.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130404 Thunderbird/17.0.5
In-Reply-To <87mws4bsum.fsf@handshake.de>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1482.1368082690.3114.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368082690 news.xs4all.nl 15928 [2001:888:2000:d::a6]:36571
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45010

Show key headers only | 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