pypy embedding into application: API...
At the moment there is following instructions provided on embedding pypy into application:
And what I have briefly tested - they do work.
However - certain areas still remains mystery to me:
If python script itself contains bugs - it's possible to get more information on error by setting
pypy_setup_home , verbose == 1.
Information is indeed printed to display - however it's missing original source code location and source code line. Also we would like to format it so it would resemble pypy command line interpreter. FYI:
Embedded into app error message: (Called by
debug: OperationError: debug: operror-type: AttributeError debug: operror-value: 'pyuv._cpyuv.Check' object has no attribute 'unref'
Started via separate shell:
pypy-nightly>pypy.exe C:\PrototypingQuick\Python_8_2021\test_evergreen.py ... Traceback (most recent call last): File "C:\PrototypingQuick\Python_8_2021\test_evergreen.py", line 4, in <module> loop = evergreen.EventLoop() File "C:\PrototypingQuick\Python_8_2021\pypy-nightly\lib\site-packages\evergreen\core\loop.py", line 126, in __init__ self._ready_processor.unref() AttributeError: 'pyuv._cpyuv.Check' object has no attribute 'unref'
We would like also to embedd multiple to be able to run multiple python scripts, where each script would run in isolation from other scripts - meaning each script is compiled and executed separately and independently from each other. Each script does not need it's own isolated separate process box - I would prefer that all scripts would run in same process and even in same thread.
What I have briefly checked through -
pypy_execute_source is implemented in
targetpypystandalone.py, which in a turn is compiled into
Creating new dynamic module at runtime + compiling python script and then scheduling for execution maybe
requires usage of
space.appexec (or similar python script), where each
space (not sure which module for use for this)
would be in a turn new instance.
Maybe you can pinpoint me good examples of dynamic module compilation with subsequent invocation ?
Flattening all threads into one (just to avoid multithreading lock issues) would in a turn require using something similar to:
but brief analysis of those libraries shows that they are maybe not the best alternative to proceed with. (compilation errors).
I'm thinking about making something similar, but would like to get your opinion on how this could be implemented.
Basically from application perspective there should be API's like:
- new task (from some .py file located either in ram or on hard disk)
- run all tasks (tasks switching occurs automatically) for some specific period of time (or interrupt all tasks or interrupt specific task running)
- stop/pause task, resume task
- delete task (and cleanup resources)
Would it be possible to provide more examples / design proposal on python integration into application ?