From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tim Meehan Newsgroups: gmane.lisp.guile.user Subject: open-pipe* seems to buffer all of my writes when I don't want it. Date: Thu, 14 Jan 2021 22:56:42 -0600 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26627"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Jan 15 05:57:13 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0HAe-0006ox-Pg for guile-user@m.gmane-mx.org; Fri, 15 Jan 2021 05:57:12 +0100 Original-Received: from localhost ([::1]:45324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0HAd-00013u-OP for guile-user@m.gmane-mx.org; Thu, 14 Jan 2021 23:57:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0HAO-00013S-Ql for guile-user@gnu.org; Thu, 14 Jan 2021 23:56:56 -0500 Original-Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:39317) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0HAM-0007EX-N1 for guile-user@gnu.org; Thu, 14 Jan 2021 23:56:56 -0500 Original-Received: by mail-qt1-x835.google.com with SMTP id a6so5273918qtw.6 for ; Thu, 14 Jan 2021 20:56:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=/EFDa7fNeqzWbeIZLKxIHb59LUVi35uskGvCPl4p94M=; b=acH541IuDHYvmY9RgEPS28Sz4IxdAk5evX72kuqKU5LQ++/iTItGcWJn4KCgInPCg+ qEsLQ3pAbI3+54yfaGbn9DUFf3FyLJG+zQT/6YhptfNwVFztmaKAY2IFBcVOpU4eDbjX /v1smhL8klZ/Hny0rpfpK5NNrv7mcZqRGyARXYfZMuDwn9qfZsr5+JyoWWXDWseT0Sy7 AwNjXXad4BfMqOiFgBDMNpASWfb7vxI2eT+Yzv4RTrnbmebSXBxcZTLOZGTLoRzENZWS Z8fMPdPsODS8v3dhvbFVZ4gMM0PgJ0WqrHU6tfLtwhiOE4SDlWhGI9aJXcS7LYNBIQsa OsVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=/EFDa7fNeqzWbeIZLKxIHb59LUVi35uskGvCPl4p94M=; b=YF4W/WdtYTsV6kHjIy6q4Xp/0NiNl4W16/vhdMmllrgVT8Vi+FjRQymS//ONzxLg2S feDxbS2PCA+WUzXL/aYFq31Ys4Kb5x/y/GvVH/J5UCENuhtd5pYWHPXxkHJhBUiC6ify Xbbni2bs4n+fiZlatJxzwMAI9xBFD3iPXvx7NtFK0jRVXrgEBmEjchsEIHpMUdri/SY+ PqCup0e8l8E9QTRswXOS/rs2bP3BGl1fYpIJSHFdwtbOpP2MGABEzFp92RB04pLsRlwc DdN8kkc/FY83K6j/vqEIVFlUddiIfAXzXCHNDywXy02CGrL8w6TY2/6tgVU8YqW8IU6Z EFrg== X-Gm-Message-State: AOAM533knxtOwxMcvHHc9YVqXnlZ4xABcb1UTu1gutBuMhAUUPxY1bDg wq0FJS+S4oN5uIzuhMArCeZatfzrsAFmWqZwLZ8XltXYkh0= X-Google-Smtp-Source: ABdhPJySuqlsgiRnan2gQJ9lMQCMpEOSVYyt3XvWedLiOhi+h0HtoLV8BhrP0HvaWOciiHJOnl94u+p0b1k+EksjEjg= X-Received: by 2002:aed:2070:: with SMTP id 103mr10380685qta.287.1610686612896; Thu, 14 Jan 2021 20:56:52 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=btmeehan@gmail.com; helo=mail-qt1-x835.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17178 Archived-At: I was trying to use Matplotlib to plot some data, through a call to "open-pipe*" ... I'm trying to slowly rewrite some of my tools in Scheme. When I run the program from the shell with "python -i plotter.py" I can send it updates ... but when I run it through Guile, it seems to store up all of my updates, then right before the program closes a window pops up for a fraction of a second and then vanishes. Am I using "open-pipe*" incorrectly? #!/usr/bin/guile !# (use-modules (ice-9 popen) (ice-9 readline) (ice-9 textual-ports)) (define program (string-concatenate '("import scipy.special\n" "import matplotlib.pyplot as plt\n" "import numpy as np\n" "x = np.linspace(0, 10)\n" "y0 = scipy.special.jv(0, x)\n" "def update_data():\n" " print('updating')\n" " noise = np.random.randn(y0.size)*0.1\n" " line1.set_ydata(y0 + noise)\n" " plt.pause(0.1)\n" "fig, ax = plt.subplots(1, 2)\n" "ax[0].plot(x, y0)\n" "ax[0].set_title('Original Data')\n" "ax[0].set_xlabel('X')\n" "ax[0].set_ylabel('Y')\n" "ax[1].plot(x, y0)\n" "line1, = ax[1].plot(x, y0, '.')\n" "ax[1].set_title('Noisy Data')\n" "ax[1].set_xlabel('X')\n" "ax[1].set_ylabel('Y')\n" "fig.show()\n" "plt.pause(0.1)\n"))) (define prompt "update? ('quit' to stop')") (define stuff (open-pipe* OPEN_WRITE "python3")) (setvbuf stuff 'none) (put-string stuff program) (force-output stuff) (let loop ([command (readline prompt)]) (unless (string-prefix? "quit" command) (display "updating\n") (put-string stuff "update_data()\n") (loop (readline prompt)))) (close-pipe stuff)