My goal is to have some IPC (two or more programs sharing information) between a Python script and another Python script (or a web page).
I want to have a "server" script which runs in a continuous loop and acting as a "database" - Not sure whether I should call that a server or database.
In the manner in which I am using the "client" script, it is executed several times per second. During every single execution of the client script, it should read from and write to the server/database several times (different parameters, different values each time).
I first tried ordinary Python socket module. This was problematic because:
#1. The socket module seems to want a fixed data length, and I cannot comply with that. The values read & written, and the number of values read & written are different each time.
#2. It does not want to run in a loop; one & done. Attempts to put it into a _while_ loop cause other things to lock up.
So I tried Python websockets, and it is the most promising so far because both of the above issues are null. It runs in a forever loop, listening and replying with any given data length. But it introduces a new problem: any script that makes a call to the "server/database" script never finishes. Because of asyncio, it makes any script that calls it into another forever loop. I cannot have this. My cyclic "client" script must run from top to bottom and end, just like a regular Python script.
Each attempt I make to read and understand how the asyncio module works makes me feel more and more like an imbecile. Can someone please explain it on the simplest level possible, and hopefully provide some tips on how to call a script running asyncio without making the calling script also asynchronous?
I want to have a "server" script which runs in a continuous loop and acting as a "database" - Not sure whether I should call that a server or database.
In the manner in which I am using the "client" script, it is executed several times per second. During every single execution of the client script, it should read from and write to the server/database several times (different parameters, different values each time).
I first tried ordinary Python socket module. This was problematic because:
#1. The socket module seems to want a fixed data length, and I cannot comply with that. The values read & written, and the number of values read & written are different each time.
#2. It does not want to run in a loop; one & done. Attempts to put it into a _while_ loop cause other things to lock up.
So I tried Python websockets, and it is the most promising so far because both of the above issues are null. It runs in a forever loop, listening and replying with any given data length. But it introduces a new problem: any script that makes a call to the "server/database" script never finishes. Because of asyncio, it makes any script that calls it into another forever loop. I cannot have this. My cyclic "client" script must run from top to bottom and end, just like a regular Python script.
Each attempt I make to read and understand how the asyncio module works makes me feel more and more like an imbecile. Can someone please explain it on the simplest level possible, and hopefully provide some tips on how to call a script running asyncio without making the calling script also asynchronous?