Skip to main content

A library for writing long running processes with a cli interface

Project description

python library for writing long running processes with a cli interface

Build Status

oi image

oi image

Usage

1. Write your long running program

# programd.py

import oi

program = oi.Program('my program', 'ipc:///tmp/program.sock')
program.add_command('ping', lambda p: 'pong')
program.add_command('state', lambda p: p.state)
program.run()  # program will run forever

2. Add a ctl interface

# programctl.py

import oi

ctl = oi.CtlProgram('ctl program', address='ipc:///tmp/program.sock')
ctl.run()

3. Run program, then connect to it via ctl

$ python programd --config /etc/program.conf

$ python programctl  # enter ctl loop
programctl > ping
pong

$ python programctl ping # OR ping end exit

Quickly get started with a new project

$ mkdir xprogram
$ cd xprogram

$ oi init
$ make install

# Start your program
$ xprogramd

# Start ctl program
$ xprogramctl
ctl > ping
pong

# Upload to pypi (Edit setup.py before distributing)
$ make distribute

Now the interesting bit. Are you ready?

Run your program on one computer, then control it from another with a single line change (actually two).

Just change the address ipc:///tmp/program.sock to a tcp address, such as tcp://192.168.1.100:5000 in both your programd.py and programctl.py. That’s it! (:

TODO

  • Add more testing

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oi-0.3.2.tar.gz (5.9 kB view details)

Uploaded Source

File details

Details for the file oi-0.3.2.tar.gz.

File metadata

  • Download URL: oi-0.3.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for oi-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e8bc223cc39e8655ac68a9f649a173801b53c68c783a724943f12daed11bec7b
MD5 32e0bb3ed18221573973b1d8c71d5b32
BLAKE2b-256 1a06a5dcf00a234680fbcfe379382c8617f849ed4743a5a632d2cc2602a2ec55

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page