~ubuntu-branches/ubuntu/precise/pyzmq/precise

« back to all changes in this revision

Viewing changes to examples/kernel/message_spec.rst

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ożarowski
  • Date: 2011-02-15 09:08:36 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110215090836-phh4slym1g6muucn
Tags: 2.0.10.1-2
* Team upload.
* Upload to unstable
* Add Breaks: ${python:Breaks}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=====================
2
 
Message Specification
3
 
=====================
4
 
 
5
 
Note: not all of these have yet been fully fleshed out, but the key ones are,
6
 
see kernel and frontend files for actual implementation details.
7
 
 
8
 
General Message Format
9
 
=====================
10
 
 
11
 
General message format::
12
 
 
13
 
    {
14
 
        header : { 'msg_id' : 10,    # start with 0
15
 
                   'username' : 'name',
16
 
                   'session' : uuid
17
 
                   },
18
 
        parent_header : dict,
19
 
        msg_type : 'string_message_type',
20
 
        content : blackbox_dict , # Must be a dict
21
 
    }
22
 
 
23
 
Side effect: (PUB/SUB)
24
 
======================
25
 
 
26
 
# msg_type = 'stream'
27
 
content = {
28
 
    name : 'stdout',
29
 
    data : 'blob',
30
 
}
31
 
 
32
 
# msg_type = 'pyin'
33
 
content = {
34
 
    code = 'x=1',
35
 
}
36
 
 
37
 
# msg_type = 'pyout'
38
 
content = {
39
 
    data = 'repr(obj)',
40
 
    prompt_number = 10
41
 
}
42
 
 
43
 
# msg_type = 'pyerr'
44
 
content = {
45
 
    traceback : 'full traceback',
46
 
    exc_type : 'TypeError',
47
 
    exc_value :  'msg'
48
 
}
49
 
 
50
 
# msg_type = 'file'
51
 
content = {
52
 
    path = 'cool.jpg',
53
 
    data : 'blob'
54
 
}
55
 
 
56
 
Request/Reply
57
 
=============
58
 
 
59
 
Execute
60
 
-------
61
 
 
62
 
Request:
63
 
 
64
 
# msg_type = 'execute_request'
65
 
content = {
66
 
    code : 'a = 10',
67
 
}
68
 
 
69
 
Reply:
70
 
 
71
 
# msg_type = 'execute_reply'
72
 
content = {
73
 
  'status' : 'ok' OR 'error' OR 'abort'
74
 
  # data depends on status value
75
 
}
76
 
 
77
 
Complete
78
 
--------
79
 
 
80
 
# msg_type = 'complete_request'
81
 
content = {
82
 
    text : 'a.f',    # complete on this
83
 
    line : 'print a.f'    # full line
84
 
}
85
 
 
86
 
# msg_type = 'complete_reply'
87
 
content = {
88
 
    matches : ['a.foo', 'a.bar']
89
 
}
90
 
 
91
 
Control
92
 
-------
93
 
 
94
 
# msg_type = 'heartbeat'
95
 
content = {
96
 
 
97
 
}