From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Two questions about atexit cleanup in dynamic modules Date: Sat, 08 Apr 2017 16:38:10 +0000 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114733c0baa707054caa5e3e X-Trace: blaine.gmane.org 1491669548 22536 195.159.176.226 (8 Apr 2017 16:39:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 8 Apr 2017 16:39:08 +0000 (UTC) To: Joris Vankerschaver , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 08 18:39:02 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cwtO6-0004g0-NV for ged-emacs-devel@m.gmane.org; Sat, 08 Apr 2017 18:38:58 +0200 Original-Received: from localhost ([::1]:55846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwtO9-0007OW-Ga for ged-emacs-devel@m.gmane.org; Sat, 08 Apr 2017 12:39:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwtNX-0007OP-7J for emacs-devel@gnu.org; Sat, 08 Apr 2017 12:38:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwtNW-0001iS-A1 for emacs-devel@gnu.org; Sat, 08 Apr 2017 12:38:23 -0400 Original-Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:36456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cwtNW-0001iD-2k for emacs-devel@gnu.org; Sat, 08 Apr 2017 12:38:22 -0400 Original-Received: by mail-wm0-x233.google.com with SMTP id o81so11650646wmb.1 for ; Sat, 08 Apr 2017 09:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=JE4gwHtzBbXgTyit9OxyD7ETUR9HN9vBatcvE0yVqJo=; b=tIJG72UpqwKwAmdQInSEX8DPfZPcU6pRFPPJHv+59hedGuaEHlp0nQLI23zG0qG8Fm 3oYYutAqVVvBap40UBKYZZoKjuajA3gyLtZI1B5TFbDlgML4A4Liypt/cLquytHwlglm N9bqd70k3PaafhCcnIOXgUQ1IU56a/4V5B3rwlilV/FMtrh4mIMKHvEJyqPxRxi9OxxH I1K9tRaBCx6MGerUwnU8r0/gt1DAOTCrsQeJKoUyPLJ5Y4fVv7latezrwV0hp0CMmN5a NoQjuCPBIh+IjEkX2XEkkiSR633bEFZjS8zK6BVhp/3dPLx/yQyaTMDDSFs6WKTuREls m3Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=JE4gwHtzBbXgTyit9OxyD7ETUR9HN9vBatcvE0yVqJo=; b=tf40Mit5dSOrX+o6uoykxDtRX20uygi7PNHYujA7OxTpC4zB4AmnuU4cS3kxHViIhe 6HNcRMobGPpX6AbDC2NEN9g8DRwqlZqW1khcpy6ER8iwG+ZAfLWj768zTLFF8z0+6Una XjGVbiZxrfZJTtLBRKzokqJZzq/A1+45A2ej22htbZ9CnB7QARXWWzXdVDx3qXJoqwcE 4bngwjrzWmeTWNToUB4kYiHPBj7/LoFOXVoEkh6S3x3YNZsYeDgUuuBlpRRP0AqQJZQA xF+2snEJV6SekUAW6dWDLknvc4xeYuGu9q6XokCmNxdS+/vjhAW0vcWNadOlQwY4kHRk 3a5A== X-Gm-Message-State: AN3rC/5Bh2I9cCB7uKl/q6aKcavR3K9Yip+li79gfHRUjPNUGlqKq6vUqVJw4w3z+hETOPhp50PuUVNPyWc9BA== X-Received: by 10.28.216.208 with SMTP id p199mr3642937wmg.44.1491669500993; Sat, 08 Apr 2017 09:38:20 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::233 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213815 Archived-At: --001a114733c0baa707054caa5e3e Content-Type: text/plain; charset=UTF-8 Joris Vankerschaver schrieb am Fr., 7. Apr. 2017 um 10:52 Uhr: > Hi all, > > I wrote a small Emacs dynamic module to execute Python scripts in an > embedded > Python interpreter (https://github.com/jvkersch/emacs-python). The main > thing > missing is that I would like to do some cleanup in the embedded Python > interpreter when Emacs exits (close open files, deal with > threads/processes, > etc). What would be the best way to do so? > > 1. Can I just register an atexit handler when my module starts, or will > that > interfere with some Emacs internals? > Unless you attempt to call Emacs functions in the atexit handler, that should be fine. > > 2. Would it make sense to add support to the module API for a cleanup > callback > that is called when Emacs exits? > You can already use the hook `kill-emacs-hook' as usual. That's especially useful if your cleanup needs to interact with Emacs. --001a114733c0baa707054caa5e3e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Joris = Vankerschaver <joris.va= nkerschaver@gmail.com> schrieb am Fr., 7. Apr. 2017 um 10:52=C2=A0Uh= r:
Hi all,

I wrote a small Emacs dynam= ic module to execute Python scripts in an embedded
Python interpreter (https://github.com/jvkersch/emacs= -python). The main thing
missing is that = I would like to do some cleanup in the embedded Python
interpreter when Emacs exits (close open files, deal with threads= /processes,
etc). What would be the best way = to do so?

1. Can I just register an atexit handler when my module= starts, or will that
interfere with some Ema= cs internals?

Unless you attemp= t to call Emacs functions in the atexit handler, that should be fine.
=
=C2=A0

2. Would it make sense to add support to the module API for = a cleanup callback
that is called when Emacs = exits?

You can already use the = hook `kill-emacs-hook' as usual. That's especially useful if your c= leanup needs to interact with Emacs.=C2=A0
--001a114733c0baa707054caa5e3e--