Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors on PyPy3 #33

Open
elonen opened this issue Nov 20, 2020 · 7 comments
Open

Errors on PyPy3 #33

elonen opened this issue Nov 20, 2020 · 7 comments

Comments

@elonen
Copy link

elonen commented Nov 20, 2020

Should the library run on PyPy? Trying pyfuse3 v3.1.1 on PyPy 7.3.2, pyfuse3 compiles, but when I tried to run/mount the hello.py example:

# python hello.py /mnt/fuse
Traceback (most recent call last):
  File "hello.py", line 157, in <module>
    main()
  File "hello.py", line 148, in main
    trio.run(pyfuse3.main)
  File "/root/test/pypyvenv/site-packages/trio/_core/_run.py", line 1928, in run
    raise runner.main_task_outcome.error
  File "/root/test/pypyvenv/site-packages/_pyfuse3.py", line 30, in wrapper
    await fn(*args, **kwargs)
  File "src/pyfuse3.pyx", line 767, in main
  File "src/pyfuse3.pyx", line 770, in pyfuse3.main
AttributeError: 'NoneType' object has no attribute 'start_soon'

Same thing with hello_async.py:

# python hello_asyncio.py /mnt/fuse
Traceback (most recent call last):
  File "hello_asyncio.py", line 162, in <module>
    main()
  File "hello_asyncio.py", line 151, in main
    loop.run_until_complete(pyfuse3.main())
  File "/usr/lib/pypy3/lib-python/3/asyncio/base_events.py", line 488, in run_until_complete
    return future.result()
  File "/usr/lib/pypy3/lib-python/3/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/lib/pypy3/lib-python/3/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/root/test/pypyvenv/site-packages/_pyfuse3.py", line 30, in wrapper
    await fn(*args, **kwargs)
  File "src/pyfuse3.pyx", line 767, in main
  File "src/pyfuse3.pyx", line 770, in pyfuse3.main
AttributeError: 'NoneType' object has no attribute 'start_soon'

Package versions:

# pip freeze
async-generator==1.10
attrs==20.3.0
cffi==1.14.2
contextvars==2.4
greenlet==0.4.13
idna==2.10
immutables==0.14
outcome==1.1.0
Pillow==8.0.1
pyfuse3==3.1.1
readline==6.2.4.1
sniffio==1.2.0
sortedcontainers==2.3.0
trio==0.17.0

Trio claims to work on PyPy, so I'm wondering what's going on here. It also seems that even the asyncio example (hello_async.py) initializes through Trio somehow.

@Nikratio
Copy link
Contributor

Thanks for the report! I am not sure what's going on here - trio.open_nursery() should return a nursery object, but in your case it returns None.

Could you run the following code directly in Pypy and check if it works?

async def foo():
        async with trio.open_nursery() as nursery:
           print(nursery)
trio.run(foo)

If this doesn't work, then my guess is that Pypi has not fully implemented the async with statement..

Regarding hello_async.py using trio - can you elaborate on what you mean? I do not see it using trio anywhere.

@elonen
Copy link
Author

elonen commented Nov 21, 2020

Both cpython and pypy returned a trio.Nursery object with that snippet:

# python test.py
<trio.Nursery object at 0x0000556fb4e42758>

The comment regarding hello_sync.py meant that since running it results in the same error on the same line, it apparently also tries to initialize using a trio.Nursery, altough the code doesn't explicly use it.

@Nikratio
Copy link
Contributor

That's quite mystifying. Exactly the same code fragment seems to give None when used in pyfuse3.pyx. Maybe it's an issue with the C code that Cython generates from this...

@Nikratio
Copy link
Contributor

(the way that asyncio support works is that the trio module is replaced by a stub, so this is expected)

@Rprabudeva
Copy link

I am actually doing project in my university, they asked me to contribute
in any one of the project in github so I want to involve in this project so
can you give permission to d

@Nikratio
Copy link
Contributor

@Rprabudeva I'm having a very hard time understanding you, but I am still confident that what you are saying is misleading at best, and downright wrong at worst. I've deleted your previous comment to prevent it from confusing others about the issue. I will leave this one as-is, but please reconsider if contributing to this project is a good fit for your skills.

@Nikratio
Copy link
Contributor

@elonen Could you also try the following please?

import functools
import trio

def async_wrapper(fn):
    @functools.wraps(fn)
    async def wrapper(*args, **kwargs):
        await fn(*args, **kwargs)
    return wrapper

@async_wrapper
async def foo():
        async with trio.open_nursery() as nursery:
           print(nursery)

trio.run(foo)

If that works, could you please install the newest Cython that you can get (ideally Git master) and rebuild everything (setup.py build_cython build_ext)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants