MCPcopy Create free account
hub / github.com/ActiveState/code / connect

Function connect

recipes/Python/577001_sqlite_message_bus/recipe-577001.py:94–110  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

92# PBULIC API
93
94def 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

Callers

nothing calls this directly

Calls 1

MBusClass · 0.85

Tested by

no test coverage detected