python-fire icon indicating copy to clipboard operation
python-fire copied to clipboard

async callable objects

Open jpic opened this issue 5 years ago • 4 comments

With the following script:

class Build:    
    async def __call__(self):    
        pass           
                       
import fire                   
fire.Fire(dict(build=Build()))

Doing ./test.py build outputs:

NAME
    test.py build

SYNOPSIS
    test.py build GROUP | COMMAND | VALUE

GROUPS
    GROUP is one of the following:

     cr_code
       code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab[, freevars[, ce$

     cr_frame

COMMANDS
    COMMAND is one of the following:

     close
       close() -> raise GeneratorExit inside coroutine.

     send
       send(arg) -> send 'arg' into coroutine, return next iterated value or raise StopIteration.

     throw
       throw(typ[,val[,tb]]) -> raise exception in coroutine, return next iterated value or raise StopIteration.

VALUES
    VALUE is one of the following:

     cr_await

     cr_origin

     cr_running

Instead of firing Build().__call__ as expected.

jpic avatar Apr 22 '20 15:04 jpic

Hello,

This is fixed in #247, ready to merge.

Best regards

jpic avatar Jul 15 '20 11:07 jpic

I notice the pr imports asyncio. Would this fix work for a script using trio?

tabbyrobin avatar Nov 04 '20 23:11 tabbyrobin

@tabbyrobin not sure, what happens when you try ?

jpic avatar Nov 05 '20 10:11 jpic

It appears to have no added ill effects, but it doesn't fix the issue either. Seems to just do the same as without it. Note: my code imports both trio and asyncio

tabbyrobin avatar Nov 06 '20 23:11 tabbyrobin