Skip to content

Latest commit

 

History

History
126 lines (84 loc) · 3.09 KB

quickstart.rst

File metadata and controls

126 lines (84 loc) · 3.09 KB

Quickstart

Install the library

pip install lahja

Import Endpoint and BaseEvent

../examples/inter_process_ping_pong.py

Setup application specific events

../examples/inter_process_ping_pong.py

../examples/inter_process_ping_pong.py

../examples/inter_process_ping_pong.py

Setup first process to receive and broadcast events

../examples/inter_process_ping_pong.py

../examples/inter_process_ping_pong.py

Setup second process to receive and broadcast events

../examples/inter_process_ping_pong.py

../examples/inter_process_ping_pong.py

Start both processes

../examples/inter_process_ping_pong.py

Running the examples

Example: Chatter between two processes

python examples/inter_process_ping_pong.py

The output will look like this:

INFO  05-29 11:31:45  Hello from proc2
INFO  05-29 11:31:45  Hello from proc1
INFO  05-29 11:31:45  Received via SUBSCRIBE API in proc2: Hit from proc1
INFO  05-29 11:31:45  Received via STREAM API in proc2: Hit from proc1
INFO  05-29 11:31:46  Hello from proc2
INFO  05-29 11:31:46  Received via SUBSCRIBE API in proc1: Hit from proc2
INFO  05-29 11:31:46  Hello from proc1
INFO  05-29 11:31:47  Hello from proc2
INFO  05-29 11:31:47  Hello from proc1
INFO  05-29 11:31:48  Hello from proc2
INFO  05-29 11:31:48  Received via SUBSCRIBE API in proc1: Hit from proc2
INFO  05-29 11:31:48  Hello from proc1
INFO  05-29 11:31:49  Hello from proc2
INFO  05-29 11:31:49  Hello from proc1
INFO  05-29 11:31:50  Hello from proc2
INFO  05-29 11:31:50  Received via SUBSCRIBE API in proc1: Hit from proc2
INFO  05-29 11:31:50  Hello from proc1
INFO  05-29 11:31:50  Received via SUBSCRIBE API in proc2: Hit from proc1
INFO  05-29 11:31:50  Received via STREAM API in proc2: Hit from proc1
INFO  05-29 11:31:51  Hello from proc2
INFO  05-29 11:31:51  Hello from proc1

Example: Request API

python examples/request_api.py

The output will look like this:

Requesting
Got answer: Yay
Requesting
Got answer: Yay
Requesting
Got answer: Yay