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

Update of processclass_remote_example.py #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

restelli
Copy link

While running the example script processclass_remote_example.py I stumbled into the following error:

Traceback (most recent call last):
  File "C:\Users\arestell\OneDrive - University of Maryland\git\zprocess\zprocess\examples\processclass_remote_example.py", line 67, in <module>
    foo = Foo(process_tree, remote_process_client=remote_process_client)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\arestell\miniconda3\envs\synchro\Lib\site-packages\zprocess-0.1.dev561+gf367fda-py3.11.egg\zprocess\process_tree.py", line 1541, in __init__
    _Process.__init__(self, *args, **kwargs)
  File "C:\Users\arestell\miniconda3\envs\synchro\Lib\site-packages\zprocess-0.1.dev561+gf367fda-py3.11.egg\zprocess\process_tree.py", line 1007, in __init__
    raise RuntimeError(msg)
RuntimeError: Cannot start a remote process for a class defined in __main__. The remote process will not be able to import the required class as it will not know the import path. Either define the class in a different module importable on both systems, or use zprocess.Process directly, passing in subclass_fullname to specify the full import path.

Noticing that the class Process is (rightfully so!) performing some extra checks before opening a task in the remote server I modified the code by adding a remote package remote_example_package that the server can refer to.

After such modification the example runs without errors.

Here what I exactly do for running the example.

  1. I start a remote server in a separate terminal by running:
python -m zprocess.remote -tui
  1. In the current terminal I run:
python processclass_remote_example.py

A typical output is:

Note: script will not work without starting a zprocess.remote server.
See comments in the script for instructions
this is a running foo in process 20268
parent, got a response: hello yourself!
data is bar
foo, got a message: hello, foo!
here

however, as expected, due to the presence of some asynchronous tasks the messages can be written in a different order such as this:

Note: script will not work without starting a zprocess.remote server.
See comments in the script for instructions
parent, got a response: hello yourself!
this is a running foo in process 12804
data is bar
foo, got a message: hello, foo!
here

I hope that what I'm doing in the example represents a correct use case for zprocess.remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant