Debian Codegraph @

doc/implnotes.rst

raw
1 gateway_base.py
2 ----------------------
3
4 The code of this module is sent to the "other side"
5 as a means of bootstrapping a Gateway object
6 capable of receiving and executing code,
7 and routing data through channels.
8
9 Gateways operate on InputOutput objects offering
10 a write and a read(n) method.
11
12 Once bootstrapped a higher level protocol
13 based on Messages is used. Messages are serialized
14 to and from InputOutput objects. The details of this protocol
15 are locally defined in this module. There is no need
16 for standardizing or versioning the protocol.
17
18 After bootstrapping the BaseGateway opens a receiver thread which
19 accepts encoded messages and triggers actions to interpret them.
20 Sending of channel data items happens directly through
21 write operations to InputOutput objects so there is no
22 separate thread.
23
24 Code execution messages are put into an execqueue from
25 which they will be taken for execution. gateway.serve()
26 will take and execute such items, one by one. This means
27 that by incoming default execution is single-threaded.
28
29 The receiver thread terminates if the remote side sends
30 a gateway termination message or if the IO-connection drops.
31 It puts an end symbol into the execqueue so
32 that serve() can cleanly finish as well.