tractor icon indicating copy to clipboard operation
tractor copied to clipboard

Use of `pydantic` and `click` in sub-actor causes SIGINT ignoring, hangs...

Open goodboy opened this issue 4 years ago • 0 comments

Ugh, i don't even know what to say about this - lost a day writing a (should take 20m) container supervisor-actor and got lost in figuring out somehow (at least on 3.10) we've got some kinda super weird SIGINT ignoring issue when combining these things.

Example code the replicates this:

import click
import pydantic
import trio
import tractor


@tractor.context
async def just_sleep(

    ctx: tractor.Context,
    **kwargs,

) -> None:
    await ctx.started()
    await trio.sleep_forever()


async def main() -> None:
    # proc = await trio.open_process(
    #     ('python',
    #      '-c',
    #      'import trio; trio.run(trio.sleep_forever)',
    #     )
    # )
    # breakpoint()
    # # import pdb
    # # pdb.set_trace()
    # await trio.sleep_forever()

    async with tractor.open_nursery(
        loglevel='runtime',
    ) as n:

        portal = await n.start_actor(
            'rpc_server',
            enable_modules=[__name__],
        )

        # XXX: syntax requires py3.9
        async with portal.open_context(
            just_sleep,  # taken from pytest parameterization
        ) as (ctx, sent):
            await trio.sleep_forever()



if __name__ == '__main__':
    # run with `sudo python -m <path.to.this>`
    trio.run(main)

I'll push up a test for this eventually as well..

goodboy avatar Feb 16 '22 14:02 goodboy