comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Running a simple Python from Ada program
Date: Fri, 3 Apr 2020 22:06:49 +0200
Date: 2020-04-03T22:06:49+02:00	[thread overview]
Message-ID: <r6850n$1p1t$1@gioia.aioe.org> (raw)
In-Reply-To: e1993dba-8fa0-4dcf-85cb-63625c704fe6@googlegroups.com

On 2020-04-03 21:19, Rego, P. wrote:
>>> Do not do that. There exist Python C API, which you should use:
>>>      https://docs.python.org/3/c-api/index.html
>> You mean that the problem is with the Python "print" ?
> 
> I tested with a very simple C code. If the Python print is blocked, it should be blocked also from a C call, I presume (ok someone will contest, anyway). Any case, from the C call, it does not block.
> 
> So I will try to simplify a bit the question. I want to do the equivalent of this
> 
>      #include <stdio.h>
>      #include <stdlib.h>
>      int main(){
>        system("python testpy.py ddddd");
>        return 0;
>      }
> In this case it does not block the testpy.py printouts.
> 
> But I am doing this
>      with Interfaces.C; use Interfaces.C;
>      procedure systest2 is
>         function Sys (Arg : Char_Array) return Integer;
>         pragma Import(C, Sys, "system");
>         Ret_Val : Integer;
>      begin
>         Ret_Val := Sys(To_C("python testpy.py arg1 arg2"));
>      end systest2;
> which blocks the testpy.py script until its end. This should not happen.

It must, actually:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/system-wsystem?view=vs-2019

> So, please, how could I fix this?

You need spawn python in an asynchronous process or else a batch script 
with something like "call python test.py ddddd" inside.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2020-04-03 20:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 16:57 Running a simple Python from Ada program Rego, P.
2020-04-03 17:35 ` Dmitry A. Kazakov
2020-04-03 19:05   ` Rego, P.
2020-04-03 19:19     ` Rego, P.
2020-04-03 20:06       ` Dmitry A. Kazakov [this message]
2020-04-04  1:48       ` Dennis Lee Bieber
2020-04-03 23:49   ` Mikhail Terekhov
2020-04-04  2:55     ` Nasser M. Abbasi
2020-04-04  8:15     ` Dmitry A. Kazakov
2020-04-04 10:44 ` fabien.chouteau
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox