Thespian icon indicating copy to clipboard operation
Thespian copied to clipboard

Assorted Windows Hiccups

Open greenbla opened this issue 2 years ago • 1 comments

Hi Kevin, Thanks for this beautiful library.:+1: You've brought the elegance of the actor model to the Python workhorse. I've been trying to get it going under windows 10 Pro. Here are some problems that I thought you'd like to know about, and maybe have insight that could help me or others.

  1. I get the following error with multiprocTCPBase or multiprocUDPBase: WARNING:root:Unable to get address info for address {my-computer-name}.Home (AddressFamily.AF_INET, SocketKind.SOCK_DGRAM, 17, 0): <class 'socket.gaierror'> [Errno 11001] getaddrinfo failed
    I can work around it by adding 127.0.0.1 {my-computer-name}.Home to my Hosts file. Is there a more ideal way?
  2. The following code:

main.py

a = ActorSystem(systemBase='multiprocTCPBase')  
b = a.createActor(Foo)  
a.ask(b,'How?')

foo.py

from thespian.initmsgs import initializing_messages
@initializing_messages(('bar',True))
class Foo(ActorTypeDispatcher):
   pass

displays creating actorsystem twice (?), and a long string of errors, ending with ActorAddr-(T|:1900) is not a valid ActorSystem admin. thespian.log says, ERR Exception in callback: When main.py is placed in a function rather than as top-level code, it errors differently. Interestingly, I don't get these errors when i put other code before the ActorSystem call. 3. I do not know how to have the user exit the script. Customarily he presses Ctrl-C, but that leaves python processes still running. They are still writing to the console and are visible in Task Manager. I've tried wrapping the code in a try except: a.shutDownActorSystem() block, a try except Exception block, or trapping signal.SIGINT, all to no avail.

greenbla avatar Feb 20 '22 21:02 greenbla

Thank you for the appreciation: it's nice to know when Thespian is useful.

Regarding your issues, let me first say that I don't have any Windows systems conveniently available, so there may be some Windows-specifics I'm not fully aware of. In more detail:

  1. The concern here is that Thespian is attempting to use a network transport and create ActorAddress instances that can be passed between Actors and be used by those Actors. In order to do this, it needs to do some basic probing to determine what address to use (most systems will have multiple network endpoints, each with a different address, allowing access on different networks). Without knowing full details of your network configuration (and likely even with that information), the solution you found is probably the best one: the assumption is that the "network name" of the current system is known to at least that system, which your Hosts file addition ensures.

  2. When starting up a network-based ActorSystem, the Thespian code attempts to create an "Admin" at a well-known address. This Admin provides the coordination between other Actors and the root actor knowledge and routing information for your current system. In order to be useable in this manner, it needs to use a well-known address and port so that Actors can connect to it. The default port used for the multiprocTCPBase is 1900. While my general past experience has been that this port is largely unused, it is possible that it could be in use by some other application running on your system; you can check for this via some Windows variant of the netstat command. You can either stop/move that application, or else choose a different specific port for Thespian to use (e.g. ActorSystem(systemBase='multiprocTCPBase', capabilities={ 'Admin Port': 12345}) as documented at https://thespianpy.com/doc/using.html#hH-9d33a877-b4f0-4012-9510-442d81b0837c).

  3. By default, Thespian starts up the Admin as a separate, long running process at the well known port to handle connection attempts. A Ctrl-C is a KeyboardInterrupt exception in python, which is normally not catchable via an except Exception handler (see https://docs.python.org/3/library/exceptions.html#KeyboardInterrupt). I would not recommend trying to catch the Ctrl-C but instead use a try... finally: a.shutdown() block (which will run the finally: block on Ctrl-C) or else use the transientUnique = True argument when creating the ActorSystem (although the result of the latter will not be able to support multi-system configurations).

kquick avatar Feb 22 '22 18:02 kquick