Integrating Python, was Re: The New Product
Nick Renders
omnis1 at arcict.com
Tue Sep 13 13:43:24 UTC 2022
Hi Stefan,
Thanks for the explanation.
It turns out I didn't install the omnis.py module correctly. This resulted in the $runstring function to work, but not the $runfile and $runtext functions.
I'll play around with the examples some more. I guess the omnis.Variable method could be used to substitute the sys.argv values in my Python script.
Cheers,
Nick
On 13 Sep 2022, at 14:56, Stefan Csomor wrote:
> Hi Nick
>
> The sample does work with your installation ?
>
> You cannot return a value from a file executed in python, only from methods. Your sample in my setup results in a "Hello World" in the Trace log though, so it is running ... I haven't added passing arguments into $runfile either. You should communicate through the omnis module using python calls as in the sample.
>
> Best,
>
> Stefan
>
> Am 13.09.22, 11:24 schrieb "omnisdev-en im Auftrag von Nick Renders" <omnisdev-en-bounces at lists.omnis-dev.com im Auftrag von omnis1 at arcict.com>:
>
> Hi Stefan,
>
> Thank you very much for sharing your oPython external.
> As a Python newbie, I am having a bit of a problem getting it to run, though.
>
> I am trying to run a simple test.py file with the following contents:
>
> print("Hello World")
>
> and the following Omnis code:
>
> Do oPy3Lib.$runfile("/Volumes/Free/test.py","__main__") Returns #S1
>
> but #S1 remains empty.
>
> I am probably making some rookie mistake.
> Is this how the $runfile function is supposed to work?
> Does it return anything that is printed?
>
> And on a related note, is it possible to specify arguments (sys.argv value) with the $runfile function?
>
>
> Thanks,
>
> Nick Renders
>
>
> On 29 May 2022, at 17:15, Stefan Csomor wrote:
>
> > Hi
> >
> >> But a good python integration literally opens up the whole of the python
> >> extensions world to be available inside Omnis.
> >
> > I've done a presentation of Python integration into Omnis in 2008, I've also pushed the code to github, updated for Python 3, https://github.com/advancedconcepts/opython but this was rather for integrating Python into the main / GUI thread.
> >
> > The problem with background language workers using python is that CPython itself is not very well suited to profit from multiple cores when multithreading - there still is a global object GIL (Global Interpreter Lock) that each thread has to acquire when active, so in order to really profit from multi-core / multi-processor machines you'd have to use a multi-process solution, which is a little bit more complex. (When your python multi-threaded code is primarily IO bound or effectively wrapping a c-library that itself is benefitting from multiple cores then things are different of course).
> >
> > Just my 0.02$
> >
> > Best,
> >
> >
> > Stefan
> >
> > _____________________________________________________________
> > Manage your list subscriptions at https://lists.omnis-dev.com
> > Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list