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

Problem to run the second sample code #6

Open
roya-correct-ai opened this issue May 13, 2020 · 2 comments
Open

Problem to run the second sample code #6

roya-correct-ai opened this issue May 13, 2020 · 2 comments

Comments

@roya-correct-ai
Copy link

Hello

I appreciate your library, also your previous response about the first sample code.
I have a problem with the second sample code, I appreciate it if you could help me with this issue.
When I run the multiprocessing code that you provided here, the following error happens:

##########################################################################
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.  File "C:\Users\royak\Programs\Python\Python36\lib\multiprocessing\spawn.py", line 105, in spawn_main

##########################################################################

there are a bunch of lines but, the error description is as above.
Could you please guide me what should I do to fix this problem?
Many thanks in advance

@rsiemens
Copy link
Owner

Hi there, sorry for the slow response getting back to you.

It sounds like you are trying to run this on windows is that correct? I had made the example quickly when using mac. Looking at this SO answer it seems like spawning child processes can cause recursive spawning if there isn't a __name__ == '__main__' guard in place.

Try changing bottom chunk of code to this:

if __name__ == '__main__':
    os1 = OS1(OS1_IP, HOST_IP)
    beam_intrinsics = json.loads(os1.get_beam_intrinsics())
    beam_alt_angles = beam_intrinsics['beam_altitude_angles']
    beam_az_angles = beam_intrinsics['beam_azimuth_angles']
    workers = spawn_workers(4, worker, unprocessed_packets, beam_alt_angles, beam_az_angles)
    os1.start()
    try:
        os1.run_forever(handler)
    except KeyboardInterrupt:
        for w in workers:
            w.terminate()

@roya-correct-ai
Copy link
Author

Thank you for your response.

I have another question, it is not related to your library but I appreciate it if you help me.
in the above code, when I try to capture the workers' outputs, each of them has its own output. How can I force them to work on the same input and the same output?
I tried to use the pool and manager, even thread, but I could not find a good way. Could you please help me with this issue?

Many thanks in advance

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

No branches or pull requests

2 participants