question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuitka doesn't work with trio.

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:24 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
leojaycommented, Jun 4, 2019

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

0reactions
kayhayencommented, Jul 26, 2022

If Trio was changed to store it on the coro object, rather than its frame, both being equally unique, it could work I think, but I don’t have the knowledge nor time to do this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuitka-chat/community - Gitter
I followed the instructions on Qt's site for how to create an async app with trio. The application builds and runs, OK, but...
Read more >
Nuitka: Compiling Python for redistribution - InfoWorld
The Nuitka project compiles a Python program to a single, ... How to avoid the dreaded circular import problem in Python (4:53).
Read more >
a Python compiler
No information is available for this page.
Read more >
Compile Python applications into stand-alone executables
IIRC a big issue with PyInstaller is that the built executables are really ... Trio doesn't work at the moment but support is...
Read more >
nuitka Changelog
When it's not done during Nuitka compile time optimization, the rich ... Added experimental plugin ``trio`` that works around issues with that package....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found