Package: jk-interprocesssync
jk_interprocesssyncIntroductionThis python module provides simple synchronization and data transfer mechanisms for processes residing on the same host.Information about this module can be found here:github.orgpypi.python.orgWhy this module?Sometimes it is necessary to implement a single application as a set of multiple processes that cooperate on a specific problem or task. If that is the case these processes need to interoperate.Limitations of this moduleAt this point, the implementation of this module is not very sophisticated. It is based on frequent polls of files or directory contents.This approach is sufficient for limited amounts of data though. For larger amounts of data you require more sophisticated approaches. These might be added to this module at some point in the future, but for today this more simple approach exists.This approach is somehow limited and costs a little bit of performance. In addition it is not extremely fast. Nevertheless if you use a RAM disk you will be able to process up to tens of thousands of data points per second.How to use this moduleImport this modulePlease include this module into your application using the following code:importjk_interprocesssync.fsBasic conceptsThen - after importing - you need to follow this approach:Instantiate an object that assists in synchronization or data transfer.Use methods on this object for signalling, data transfer, waiting for signals or to wait for incoming data.More about this is explained in the next sections.Regular EventsIntroductionA regular event is a synchronization mechanism that has two operations:sender :signal: signal the event;listener :wait: blocks until it receives a signal; autoreset the signal;This mechanism is implemented byEvent.NOTE: This implementation is to work in situations with ...a single sender and a single listenera single sender and multiple listenersImplement a senderExample:evt=jk_interprocesssync.fs.Event("/my/dir/to/eventfile")whileTrue:...dosomething...evt.signal()Implement a listenerExample:evt=jk_interprocesssync.fs.Event("/my/dir/to/eventfile")for_inevt.waitG():...dosomething...JSON Data EventsIntroductionA JSON data event is a synchronization mechanism that has two operations:sender :signal: signal the event; additionally pass data to the listener;listener :wait: blocks until it receives a signal; autoreset the signal; the data sent by the sender is returend and can be processed by the listener;This mechanism is implemented byJSONDataEvent.NOTE: This implementation is to work in situations with ...a single sender and a single listenerImplement a senderExample:evt=jk_interprocesssync.fs.JSONDataEvent("/my/dir/to/ramdisk/eventfile")whileTrue:...dosomething...evt.signal(...data...)Implement a listenerExample:evt=jk_interprocesssync.fs.JSONDataEvent("/my/dir/to/ramdisk/eventfile")fordatainevt.waitG():...dosomethingusingthedata...JSON Data QueueIntroductionA JSON data event is a synchronization mechanism that has two operations:sender :put: put data into the queue; notifies the listener;listener :get: blocks until it receives data; automatically remove the data from the queue;This mechanism is implemented byJSONDataQueue.NOTE: This implementation is to work in situations with ...a single sender and a single listenera single sender and a multiple listenersa multiple senders and a single listenera multiple senders and multiple listenersImplement a senderExample:queue=jk_interprocesssync.fs.JSONDataQueue("/my/dir/to/ramdisk/queuedir")whileTrue:...dosomething...queue.put(...data...)Implement a listenerExample:queue=jk_interprocesssync.fs.JSONDataQueue("/my/dir/to/ramdisk/queuedir")fordatainqueue.getG():...dosomethingusingthedata...Contact InformationThis work is Open Source. This enables you to use this work for free.Please have in mind this also enables you to contribute. We, the subspecies of software developers, can create great things. But the more collaborate, the more fantastic these things can become. Therefore Feel free to contact the author(s) listed below, either for giving feedback, providing comments, hints, indicate possible collaborations, ideas, improvements. Or maybe for "only" reporting some bugs:Jürgen Knauth:jknauth@uni-goettingen.de,pubsrc@binary-overflow.deLicenseThis software is provided under the following license:Apache Software License 2.0