Create a MBus and populate module environment with it's global methods. The common case is that we connect to only one message bus. To avoid passing around a message bus object we can instead simply do: import mbus mbus.connect(db, 'client') mbus.send('*', 'ping') for rowi
(db, name)
| 92 | # PBULIC API |
| 93 | |
| 94 | def connect (db, name): |
| 95 | """Create a MBus and populate module environment with it's global methods. |
| 96 | |
| 97 | The common case is that we connect to only one message bus. To avoid passing |
| 98 | around a message bus object we can instead simply do: |
| 99 | |
| 100 | import mbus |
| 101 | |
| 102 | mbus.connect(db, 'client') |
| 103 | mbus.send('*', 'ping') |
| 104 | for rowid, source, tag, data in mbus.recv(tag='pong'): |
| 105 | pass |
| 106 | """ |
| 107 | g = globals() |
| 108 | m = MBus(db, name) |
| 109 | g['send'] = m.send |
| 110 | g['recv'] = m.recv |
| 111 | |
| 112 | |
| 113 |