Recently I've been experimenting with discord bots, which use asyncio. I've been in the process of making a program that controls lots of other bots, opening and closing them on the fly, but I have a problem; I've experimented with subprocess.Popen, rpyc and multiprocessing, but I'm struggling to work out how to have communication between programs. I've tried using the following line of code to launch the subprocesses:
Popen('python smallprogram.py', stdout=PIPE, stdin=PIPE)
but I'm still unable to communicate from the main program to the smaller programs, due to the smaller ones needing to run asyncio. This prevents me from using input() with Popen.communicate(). Ideally, I'd like a way to call a function on the smaller program when needed, with the small program still running asyncio. I don't mind having to paste the same block of code into each of the smaller programs, but I think this might also be solvable with some importations?
Can this be done? I've never made an API before, but it seems I might need to use API as a template. Thank you :)
Note: I only need to do big->small communication, but doing it the other way round would be nice too.