Why is this fork not working?

Hi there! I have run into a problem that I just don’t seem to be able to slve,

When I run the ttone() function directly it behaves as it should. However if I run it in a fork() then only the first print happens and then the program hangs. Anyone have any idea why?
Thanks
Example4.py (688 Bytes)

Quick solution! s.wait_for_children_to_finish should be s.wait_for_children_to_finish(). You need to call the function. :slight_smile:

Also, when you post code here, you can surround it with triple backslashes (```), which should keep the formatting.

Thanks Marc. I knew I was doing something stupid!

BTW would a function like wait_for_clock_to_finish() a good idea? You could use that to wait for a forked process to finish (fork() does return a clock doesn’t it?) to start another process while some running processes are still going.

You mean, wait for a specific clock to finish? You know, I’ve been wondering about that. It’s not a bad idea!

I haven’t put it in an official release yet I think, but I did recently give fork an argument called done_callback that takes a function to call when the clock finishes. But maybe wait_for_clock_to_finish() is better.