Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: multiprocessing causes KeyError: '__mp_main__' #79

Closed
goodboy opened this issue Oct 15, 2019 · 1 comment
Closed

Windows: multiprocessing causes KeyError: '__mp_main__' #79

goodboy opened this issue Oct 15, 2019 · 1 comment
Labels

Comments

@goodboy
Copy link
Owner

goodboy commented Oct 15, 2019

This is an issue that can show up on windows without special construction of a __main__ script in a python program using tractor.

When running the first example in a script the traceback log will look something like the following output:

Click to show log
No actor could be found @ 127.0.0.1:1616
Alright... Action!
already have channel(s) for ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748'):[<Channel fd=148, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60548)>]?
already have channel(s) for ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748'):[<Channel fd=148, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60548)>, <Channel fd=636, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60549)>]?
already have channel(s) for ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748'):[<Channel fd=640, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60556)>]?
already have channel(s) for ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748'):[<Channel fd=640, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60556)>, <Channel fd=624, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60557)>]?
Actor errored:
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 127, in _invoke
    await chan.send({'return': await coro, 'cid': cid})
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 14, in say_hello
    return await portal.run(_this_module, 'hi')
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 203, in run
    *(await self._submit(ns, func, kwargs))
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 184, in _submit
    raise unpack_error(first_msg, self.channel)
tractor._exceptions.RemoteActorError: ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 234, in _get_rpc_func
    return getattr(self._mods[ns], funcname)
KeyError: '__mp_main__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 425, in _process_messages
    func = self._get_rpc_func(ns, funcname)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 236, in _get_rpc_func
    raise ModuleNotExposed(*err.args)
tractor._exceptions.ModuleNotExposed: __mp_main__

Actor errored:
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 127, in _invoke
    await chan.send({'return': await coro, 'cid': cid})
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 14, in say_hello
    return await portal.run(_this_module, 'hi')
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 203, in run
    *(await self._submit(ns, func, kwargs))
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 184, in _submit
    raise unpack_error(first_msg, self.channel)
tractor._exceptions.RemoteActorError: ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 234, in _get_rpc_func
    return getattr(self._mods[ns], funcname)
KeyError: '__mp_main__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 425, in _process_messages
    func = self._get_rpc_func(ns, funcname)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 236, in _get_rpc_func
    raise ModuleNotExposed(*err.args)
tractor._exceptions.ModuleNotExposed: __mp_main__

Nursery for ('arbiter', 'e1c90c88-3ff6-11e9-868f-605718da7748') errored with <class 'tractor._exceptions.RemoteActorError'>,
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 224, in _return_from_resptype
    return msg['return']
KeyError: 'return'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 329, in open_nursery
    yield nursery
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 35, in main
    print(await gretchen.result())
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 261, in result
    raise self._result
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 254, in result
    *self._expect_result
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 228, in _return_from_resptype
    raise unpack_error(msg, self.channel)
tractor._exceptions.RemoteActorError: ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 127, in _invoke
    await chan.send({'return': await coro, 'cid': cid})
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 14, in say_hello
    return await portal.run(_this_module, 'hi')
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 203, in run
    *(await self._submit(ns, func, kwargs))
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 184, in _submit
    raise unpack_error(first_msg, self.channel)
tractor._exceptions.RemoteActorError: ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 234, in _get_rpc_func
    return getattr(self._mods[ns], funcname)
KeyError: '__mp_main__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 425, in _process_messages
    func = self._get_rpc_func(ns, funcname)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 236, in _get_rpc_func
    raise ModuleNotExposed(*err.args)
tractor._exceptions.ModuleNotExposed: __mp_main__


Sending actor cancel request to ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748') on <Channel fd=148, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60548)>
Sending actor cancel request to ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748') on <Channel fd=640, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60556)>
Task <bound method Actor.cancel of <tractor._actor.Actor object at 0x0000021DE5606B38>> was likely cancelled before it was started
Task <bound method Actor.cancel of <tractor._actor.Actor object at 0x0000026F646D7C50>> was likely cancelled before it was started
already have channel(s) for ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748'):[<Channel fd=640, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60556)>]?
already have channel(s) for ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748'):[<Channel fd=148, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 60548)>]?
May have failed to cancel ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
May have failed to cancel ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
This portal is already closed can't cancel
Cancelling existing result waiter task for ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
This portal is already closed can't cancel
Cancelling existing result waiter task for ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 224, in _return_from_resptype
    return msg['return']
KeyError: 'return'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 133, in exhaust_portal
    final = res = await portal.result()
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 261, in result
    raise self._result
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 329, in open_nursery
    yield nursery
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 35, in main
    print(await gretchen.result())
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 261, in result
    raise self._result
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 254, in result
    *self._expect_result
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 228, in _return_from_resptype
    raise unpack_error(msg, self.channel)
tractor._exceptions.RemoteActorError: ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 127, in _invoke
    await chan.send({'return': await coro, 'cid': cid})
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 14, in say_hello
    return await portal.run(_this_module, 'hi')
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 203, in run
    *(await self._submit(ns, func, kwargs))
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 184, in _submit
    raise unpack_error(first_msg, self.channel)
tractor._exceptions.RemoteActorError: ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 234, in _get_rpc_func
    return getattr(self._mods[ns], funcname)
KeyError: '__mp_main__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 425, in _process_messages
    func = self._get_rpc_func(ns, funcname)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 236, in _get_rpc_func
    raise ModuleNotExposed(*err.args)
tractor._exceptions.ModuleNotExposed: __mp_main__



During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 42, in <module>
    tractor.run(main, spawn_method='spawn')
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\__init__.py", line 104, in run
    return trio.run(_main, async_fn, args, kwargs, name, arbiter_addr)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\trio\_core\_run.py", line 1444, in run
    raise runner.main_task_outcome.error
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\__init__.py", line 87, in _main
    actor, main, host, port, arbiter_addr=arbiter_addr)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 832, in _start_actor
    result = await main()
  File "A:\tractor_examples\ex01_trynamic_scene.py", line 37, in main
    print("CUTTTT CUUTT CUT!!! Donny!! You're supposed to say...")
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\async_generator\_util.py", line 53, in __aexit__
    await self._agen.athrow(type, value, traceback)
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 329, in open_nursery
    yield nursery
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 300, in __aexit__
    await self.cancel()
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 280, in cancel
    await self.wait()
  File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 235, in wait
    raise trio.MultiError(errors)
trio.MultiError: RemoteActorError('(\'donny\', \'e1c97da6-3ff6-11e9-bb69-605718da7748\')\nTraceback (most recent call last):\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 127, in _invoke\n    await chan.send({\'return\': await coro, \'cid\': cid})\n  File "A:\\tractor_examples\\ex01_trynamic_scene.py", line 14, in say_hello\n    return await portal.run(_this_module, \'hi\')\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_portal.py", line 203, in run\n    *(await self._submit(ns, func, kwargs))\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_portal.py", line 184, in _submit\n    raise unpack_error(first_msg, self.channel)\ntractor._exceptions.RemoteActorError: (\'gretchen\', \'e1eb5e08-3ff6-11e9-a581-605718da7748\')\nTraceback (most recent call last):\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 234, in _get_rpc_func\n    return getattr(self._mods[ns], funcname)\nKeyError: \'__mp_main__\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 425, in _process_messages\n    func = self._get_rpc_func(ns, funcname)\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 236, in _get_rpc_func\n    raise ModuleNotExposed(*err.args)\ntractor._exceptions.ModuleNotExposed: __mp_main__\n\n'), RemoteActorError('(\'gretchen\', \'e1eb5e08-3ff6-11e9-a581-605718da7748\')\nTraceback (most recent call last):\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 127, in _invoke\n    await chan.send({\'return\': await coro, \'cid\': cid})\n  File "A:\\tractor_examples\\ex01_trynamic_scene.py", line 14, in say_hello\n    return await portal.run(_this_module, \'hi\')\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_portal.py", line 203, in run\n    *(await self._submit(ns, func, kwargs))\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_portal.py", line 184, in _submit\n    raise unpack_error(first_msg, self.channel)\ntractor._exceptions.RemoteActorError: (\'donny\', \'e1c97da6-3ff6-11e9-bb69-605718da7748\')\nTraceback (most recent call last):\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 234, in _get_rpc_func\n    return getattr(self._mods[ns], funcname)\nKeyError: \'__mp_main__\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 425, in _process_messages\n    func = self._get_rpc_func(ns, funcname)\n  File "C:\\ProgramData\\Miniconda3\\envs\\tractor19030601\\lib\\site-packages\\tractor\\_actor.py", line 236, in _get_rpc_func\n    raise ModuleNotExposed(*err.args)\ntractor._exceptions.ModuleNotExposed: __mp_main__\n\n')

Details of embedded exception 1:

  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 224, in _return_from_resptype
      return msg['return']
  KeyError: 'return'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 133, in exhaust_portal
      final = res = await portal.result()
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 261, in result
      raise self._result
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 254, in result
      *self._expect_result
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 228, in _return_from_resptype
      raise unpack_error(msg, self.channel)
  tractor._exceptions.RemoteActorError: ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 127, in _invoke
      await chan.send({'return': await coro, 'cid': cid})
    File "A:\tractor_examples\ex01_trynamic_scene.py", line 14, in say_hello
      return await portal.run(_this_module, 'hi')
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 203, in run
      *(await self._submit(ns, func, kwargs))
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 184, in _submit
      raise unpack_error(first_msg, self.channel)
  tractor._exceptions.RemoteActorError: ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 234, in _get_rpc_func
      return getattr(self._mods[ns], funcname)
  KeyError: '__mp_main__'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 425, in _process_messages
      func = self._get_rpc_func(ns, funcname)
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 236, in _get_rpc_func
      raise ModuleNotExposed(*err.args)
  tractor._exceptions.ModuleNotExposed: __mp_main__



Details of embedded exception 2:

  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 133, in exhaust_portal
      final = res = await portal.result()
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 261, in result
      raise self._result
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_trionics.py", line 329, in open_nursery
      yield nursery
    File "A:\tractor_examples\ex01_trynamic_scene.py", line 35, in main
      print(await gretchen.result())
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 261, in result
      raise self._result
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 254, in result
      *self._expect_result
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 228, in _return_from_resptype
      raise unpack_error(msg, self.channel)
  tractor._exceptions.RemoteActorError: ('gretchen', 'e1eb5e08-3ff6-11e9-a581-605718da7748')
  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 127, in _invoke
      await chan.send({'return': await coro, 'cid': cid})
    File "A:\tractor_examples\ex01_trynamic_scene.py", line 14, in say_hello
      return await portal.run(_this_module, 'hi')
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 203, in run
      *(await self._submit(ns, func, kwargs))
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_portal.py", line 184, in _submit
      raise unpack_error(first_msg, self.channel)
  tractor._exceptions.RemoteActorError: ('donny', 'e1c97da6-3ff6-11e9-bb69-605718da7748')
  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 234, in _get_rpc_func
      return getattr(self._mods[ns], funcname)
  KeyError: '__mp_main__'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 425, in _process_messages
      func = self._get_rpc_func(ns, funcname)
    File "C:\ProgramData\Miniconda3\envs\tractor19030601\lib\site-packages\tractor\_actor.py", line 236, in _get_rpc_func
      raise ModuleNotExposed(*err.args)
  tractor._exceptions.ModuleNotExposed: __mp_main__

The issue was first described by @chrizzFTD in #61. @rahulraj80 also experienced this but was able to use @chrizzFTD's solution to get a similar working result. This solution is based on this SO question.

We need to document this solution under the windows gotchas in the readme such that it's available for easy reference.

@goodboy
Copy link
Owner Author

goodboy commented Oct 15, 2019

To repeat, this is the script and logging result that @rahulraj80 obtained with solution applied:

The entire contents of the runner Script:

# Tractor_Training_runner.py
import tractor
import multiprocessing
#from . import TractorTraining

import os
os.chdir(r"c:/users/rahul/source/repos/TwistedTraining/TwistedTraining/TwistedTraining")
import TractorTraining



if __name__ == '__main__':
    multiprocessing.freeze_support()
    tractor.run(TractorTraining.main)

Log:
...:

No actor could be found @ 127.0.0.1:1616
Alright... Action!
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tractor\_actor.py:237: TrioDeprecationWarning: trio.Event.clear is deprecated since Trio 0.12.0; use multiple Event objects or other synchronization primitives instead (https://github.com/python-trio/trio/issues/637)
  self._no_more_peers.clear()
already have channel(s) for ('donny', 'd356fbe2-9806-4b4a-abb7-9a9e3b93209a'):[<Channel fd=1248, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2187)>]?
already have channel(s) for ('donny', 'd356fbe2-9806-4b4a-abb7-9a9e3b93209a'):[<Channel fd=1248, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2187)>, <Channel fd=1284, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2188)>]?
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\tractor\_actor.py:450: TrioDeprecationWarning: trio.Event.clear is deprecated since Trio 0.12.0; use multiple Event objects or other synchronization primitives instead (https://github.com/python-trio/trio/issues/637)
  self._no_more_rpc_tasks.clear()
already have channel(s) for ('gretchen', 'cf7a6f6b-a022-44e0-87ee-e73b36dcebd7'):[<Channel fd=1300, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2195)>]?
already have channel(s) for ('gretchen', 'cf7a6f6b-a022-44e0-87ee-e73b36dcebd7'):[<Channel fd=1300, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2195)>, <Channel fd=1236, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2196)>]?
Hi my name is donny
Hi my name is gretchen
CUTTTT CUUTT CUT!!! Donny!! You're supposed to say...
Sending actor cancel request to ('donny', 'd356fbe2-9806-4b4a-abb7-9a9e3b93209a') on <Channel fd=1248, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2187)>
Sending actor cancel request to ('gretchen', 'cf7a6f6b-a022-44e0-87ee-e73b36dcebd7') on <Channel fd=1300, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2195)>
already have channel(s) for ('donny', 'd356fbe2-9806-4b4a-abb7-9a9e3b93209a'):[<Channel fd=1248, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2187)>]?
already have channel(s) for ('gretchen', 'cf7a6f6b-a022-44e0-87ee-e73b36dcebd7'):[<Channel fd=1300, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 1616), raddr=('127.0.0.1', 2195)>]?
Cancelling existing result waiter task for ('donny', 'd356fbe2-9806-4b4a-abb7-9a9e3b93209a')
Cancelling existing result waiter task for ('gretchen', 'cf7a6f6b-a022-44e0-87ee-e73b36dcebd7')
May have failed to cancel ('donny', 'd356fbe2-9806-4b4a-abb7-9a9e3b93209a')
May have failed to cancel ('gretchen', 'cf7a6f6b-a022-44e0-87ee-e73b36dcebd7')

The cancellation reporting at the end is expected with the "warn" level logging enabled. I'm not sure if all of these messages should be "warn" level since a lot of them are expected during graceful teardown. An example where "info" level might be better is here.

This was referenced Oct 15, 2019
goodboy added a commit that referenced this issue Oct 16, 2019
Fill out with the solution from #79 and move the section further down.
This should hopefully suffice what's left to fulfil for #59

Resolves #79
goodboy added a commit that referenced this issue Oct 16, 2019
Fill out with the solution from #79 and move the section further down.
This should hopefully suffice what's left to fulfil for #59

Resolves #79
goodboy added a commit that referenced this issue Jan 29, 2020
Thanks to @salotz for pointing out that the first example in the docs
was broken. Though it's somewhat embarrassing this might also explain
the problem in #79 and certain issues in #59...

The solution here is to import the target RPC module using the its
unique basename and absolute filepath in the sub-actor that requires it.
Special handling for `__main__` and `__mp_main__` is needed since the
spawned subprocess will have no knowledge about these parent-
-state-specific module variables. Solution: map the modules name to the
respective module file basename in the child process since the module
variables will of course have different values in children.
goodboy added a commit that referenced this issue Jan 29, 2020
Thanks to @salotz for pointing out that the first example in the docs
was broken. Though it's somewhat embarrassing this might also explain
the problem in #79 and certain issues in #59...

The solution here is to import the target RPC module using the its
unique basename and absolute filepath in the sub-actor that requires it.
Special handling for `__main__` and `__mp_main__` is needed since the
spawned subprocess will have no knowledge about these parent-
-state-specific module variables. Solution: map the modules name to the
respective module file basename in the child process since the module
variables will of course have different values in children.
goodboy added a commit that referenced this issue Jan 29, 2020
Thanks to @salotz for pointing out that the first example in the docs
was broken. Though it's somewhat embarrassing this might also explain
the problem in #79 and certain issues in #59...

The solution here is to import the target RPC module using the its
unique basename and absolute filepath in the sub-actor that requires it.
Special handling for `__main__` and `__mp_main__` is needed since the
spawned subprocess will have no knowledge about these parent-
-state-specific module variables. Solution: map the modules name to the
respective module file basename in the child process since the module
variables will of course have different values in children.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant