Nuitka: Nuitka doesn't work with trio.

I’m using Nuitka 0.6.3.1 and Python 3.6.5 in a venv environment on a linux machine. I installed Nuitka and trio with command:

pip install Nuitka trio

trio is an async library. https://github.com/python-trio/trio

I have a file t.py like this:

import trio

async def main():
  print('hello')

trio.run(main)

If I run the script directly, everything is fine.

$ python t.py 
hello

But if I compile the script with Nuitka, it doesn’t run anymore

$ python -m nuitka t.py 
Nuitka:WARNING:Not recursing to 'trio' (/home/leojay/test/py3test/lib/python3.6/site-packages/trio), please specify --nofollow-imports (do not warn), --follow-imports (recurse to all), --nofollow-import-to=trio (ignore it), --follow-import-to=trio (recurse to it) to change.
$ ./t.bin
Traceback (most recent call last):
  File "/home/leojay/test/py3test/t.py", line 6, in <module>
    trio.run(main)
  File "/home/leojay/test/py3test/lib/python3.6/site-packages/trio/_core/_run.py", line 1430, in run
    run_impl(runner, async_fn, args)
  File "/home/leojay/test/py3test/lib/python3.6/site-packages/trio/_core/_run.py", line 1579, in run_impl
    runner.task_exited(task, final_outcome)
  File "/home/leojay/test/py3test/lib/python3.6/site-packages/trio/_core/_run.py", line 1064, in task_exited
    raise TrioInternalError
trio.TrioInternalError

I expect the script to output hello, instead of throwing an exception. Can you please take a look at this? Thanks!

Leo

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 25 (24 by maintainers)

Most upvoted comments

Hi,

I managed to reproduce the second problem with relatively simple code. Here is my code structure:

$ tree
.
├── a
│   ├── b
│   │   ├── c.py
│   │   └── __init__.py
│   └── __init__.py
└── atest.py

Here are the contents of all files:

$ cat atest.py 
import a
$ cat a/__init__.py
from .b import *
$ cat a/b/__init__.py 
def hello():
    print('hello from b')

from .c import *
$ cat a/b/c.py 
from .. import b
b.hello()

When running the code directly, everything is fine:

$ python atest.py 
hello from b

But when running the compiled code, it shows an import error:

$ python -m nuitka atest.py --follow-import-to=a
$ ./atest.bin 
Traceback (most recent call last):
  File "/home/leo/test/triotest/importtest/atest.py", line 1, in <module>
    import a
  File "/home/leo/test/triotest/importtest/a/__init__.py", line 1, in <module a>
    from .b import *
  File "/home/leo/test/triotest/importtest/a/b/__init__.py", line 4, in <module a.b>
    from .c import *
  File "/home/leo/test/triotest/importtest/a/b/c.py", line 1, in <module a.b.c>
    from .. import b
ImportError: cannot import name 'b' from 'a' (/home/leo/test/triotest/importtest/a/__init__.py)

Hope this helps.

Leo