Skip to main content

ThingsDB module builder

Project description

timod

Library for creating ThingsDB modules using the Python language

Installation

$ pip install py-timod

Usage

Modules for ThingsDB read from stdin and write a response back to stdout. Work by the module must be non-blocking.

If the module requires configuration data, for example a connection string, then this configuration will be send immediately after start-up but may be received again when the module configuration is changed in ThingsDB.

Do not use functions like print since these function will write to stdout and this is reserved for ThingsDB. Instead, use logging... to write to stderr instead.

The following code may be used as a template: (see: https://github.com/thingsdb/ThingsDB/tree/master/modules/python/demo.py)

import logging
from timod import start_module, TiHandler, LookupError


class Handler(TiHandler):

    async def on_config(self, cfg):
        logging.info(cfg)

    async def on_request(self, req):
        if 'message' not in req:
            raise LookupError('missing `message` in request')

        return req['message']


if __name__ == '__main__':
    start_module('demo', Handler())

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

py-timod-0.0.6.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file py-timod-0.0.6.tar.gz.

File metadata

  • Download URL: py-timod-0.0.6.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for py-timod-0.0.6.tar.gz
Algorithm Hash digest
SHA256 9bd27496257451fc48e57de0ee097fe1b9bf27c1e1cd3792c35ff79a00831593
MD5 7e67af9aba76cdc064d606175ab05d34
BLAKE2b-256 58e563f11c90e060089d0840131b5a625bd3f79063dbe6c2af817754463da883

See more details on using hashes here.

Supported by

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