Skip to content

Update of processclass_remote_example.py#21

Open
restelli wants to merge 2 commits intochrisjbillington:masterfrom
restelli:fix_old_example
Open

Update of processclass_remote_example.py#21
restelli wants to merge 2 commits intochrisjbillington:masterfrom
restelli:fix_old_example

Conversation

@restelli
Copy link
Copy Markdown

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