examples: import client/server.py test scripts as examples

This commit is contained in:
David Wilson 2018-02-15 06:17:07 +05:45
parent ac4a42a43e
commit 2a097dfaf8
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import socket
import mitogen.master
import mitogen.unix
import mitogen.service
import mitogen.utils
PING = 500
mitogen.utils.log_to_file()
router, parent = mitogen.unix.connect('/tmp/mitosock')
with router:
print mitogen.service.call(parent, CONNECT_BY_ID, {})

View File

@ -0,0 +1,25 @@
# The service framework will fundamentally change (i.e. become much nicer, and
# hopefully lose those hard-coded magic numbers somehow), but meanwhile this is
# a taster of how it looks today.
import time
import mitogen
import mitogen.service
import mitogen.unix
class PingService(mitogen.service.Service):
well_known_id = 500
max_message_size = 1000
def dispatch(self, dct, msg):
return 'Hello, world'
@mitogen.main()
def main(router):
listener = mitogen.unix.Listener(router, path='/tmp/mitosock')
service = PingService(router)
service.run()