wait_for_actor #5

Open
opened 2024-09-19 07:02:07 +00:00 by jc211 · 0 comments

wait_for_actor freezes when called with on an actor with address 127.0.0.1

Repro:

#client.py
import tractor
import trio
import endpoints

log = tractor.log.get_console_log(
    _root_name='my_app',
    name='client',
)

async def client_main():
    tractor.log.get_console_log(
        level='info',
        _root_name='my_app',
        name='client',
    )

    async with (
        tractor.open_root_actor(
            name='client',
            registry_addrs=[('127.0.01', 1616)],
            enable_modules=[],  # since this isn't a service actor
            debug_mode=True
        ),

        tractor.wait_for_actor(
            name='server',
            registry_addr=('127.0.0.1', 1616),
        ) as portal,

    ):
        res = await portal.run(endpoints.my_func, name='tractor')
        print(res)
        
if __name__ == '__main__':
    trio.run(client_main)
#server.py
import tractor
import trio

log = tractor.log.get_console_log(
    _root_name='my_app',
    name='server_thingy',
)

async def main():
    tractor.log.get_console_log(
        level='info',
        _root_name='my_app',
        name='server_thingy',
    )

    this_mod: str = 'endpoints'
    async with tractor.open_root_actor(
        name='server',
        registry_addrs=[('127.0.01', 1616)],
        enable_modules=[this_mod],
        loglevel='debug',
        debug_mode=True
    ):
    
        log.info(
            'proxy server up bby!\n'
            'waiting to serve some requests..\n'
        )
        await trio.sleep_forever()


if __name__ == '__main__':
    trio.run(main)
#endpoints.py
async def my_func(name):
    return f'hello {name}'
`wait_for_actor ` freezes when called with on an actor with address 127.0.0.1 Repro: ```python #client.py import tractor import trio import endpoints log = tractor.log.get_console_log( _root_name='my_app', name='client', ) async def client_main(): tractor.log.get_console_log( level='info', _root_name='my_app', name='client', ) async with ( tractor.open_root_actor( name='client', registry_addrs=[('127.0.01', 1616)], enable_modules=[], # since this isn't a service actor debug_mode=True ), tractor.wait_for_actor( name='server', registry_addr=('127.0.0.1', 1616), ) as portal, ): res = await portal.run(endpoints.my_func, name='tractor') print(res) if __name__ == '__main__': trio.run(client_main) ``` ```python #server.py import tractor import trio log = tractor.log.get_console_log( _root_name='my_app', name='server_thingy', ) async def main(): tractor.log.get_console_log( level='info', _root_name='my_app', name='server_thingy', ) this_mod: str = 'endpoints' async with tractor.open_root_actor( name='server', registry_addrs=[('127.0.01', 1616)], enable_modules=[this_mod], loglevel='debug', debug_mode=True ): log.info( 'proxy server up bby!\n' 'waiting to serve some requests..\n' ) await trio.sleep_forever() if __name__ == '__main__': trio.run(main) ``` ``` #endpoints.py async def my_func(name): return f'hello {name}' ```
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: goodboy/tractor#5
There is no content yet.