forked from goodboy/tractor
				
			Always set default reg addr in `find_actor()` if not defined
							parent
							
								
									43b659dbe4
								
							
						
					
					
						commit
						87c1113de4
					
				| 
						 | 
					@ -22,6 +22,7 @@ management of (service) actors.
 | 
				
			||||||
from __future__ import annotations
 | 
					from __future__ import annotations
 | 
				
			||||||
from typing import (
 | 
					from typing import (
 | 
				
			||||||
    AsyncGenerator,
 | 
					    AsyncGenerator,
 | 
				
			||||||
 | 
					    AsyncContextManager,
 | 
				
			||||||
    TYPE_CHECKING,
 | 
					    TYPE_CHECKING,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
from contextlib import asynccontextmanager as acm
 | 
					from contextlib import asynccontextmanager as acm
 | 
				
			||||||
| 
						 | 
					@ -190,11 +191,19 @@ async def find_actor(
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                yield None
 | 
					                yield None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async with gather_contexts(
 | 
					    if not registry_addrs:
 | 
				
			||||||
        mngrs=list(
 | 
					        from ._root import _default_lo_addrs
 | 
				
			||||||
 | 
					        registry_addrs = _default_lo_addrs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    maybe_portals: list[
 | 
				
			||||||
 | 
					        AsyncContextManager[tuple[str, int]]
 | 
				
			||||||
 | 
					    ] = list(
 | 
				
			||||||
        maybe_open_portal_from_reg_addr(addr)
 | 
					        maybe_open_portal_from_reg_addr(addr)
 | 
				
			||||||
        for addr in registry_addrs
 | 
					        for addr in registry_addrs
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async with gather_contexts(
 | 
				
			||||||
 | 
					        mngrs=maybe_portals,
 | 
				
			||||||
    ) as maybe_portals:
 | 
					    ) as maybe_portals:
 | 
				
			||||||
        print(f'Portalz: {maybe_portals}')
 | 
					        print(f'Portalz: {maybe_portals}')
 | 
				
			||||||
        if not maybe_portals:
 | 
					        if not maybe_portals:
 | 
				
			||||||
| 
						 | 
					@ -206,6 +215,9 @@ async def find_actor(
 | 
				
			||||||
            yield portals[0]
 | 
					            yield portals[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
 | 
					            # TODO: currently this may return multiple portals
 | 
				
			||||||
 | 
					            # given there are multi-homed or multiple registrars..
 | 
				
			||||||
 | 
					            # SO, we probably need de-duplication logic?
 | 
				
			||||||
            yield portals
 | 
					            yield portals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue