Skip to main content

CI Release Version

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 typing import Any
from timod import start_module, TiHandler, LookupError


class Handler(TiHandler):

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

    async def on_request(self, req: dict[str, Any]):
        if 'message' not in req:
            raise LookupError('missing `message` in request')

        return req['message']


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

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-1.0.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_timod-1.0.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file py_timod-1.0.0.tar.gz.

File metadata

  • Download URL: py_timod-1.0.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for py_timod-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3d32b267c18e11f4244416fe890671d1dbd47c11b8530a594ce0fc055238d27d
MD5 19f48546ef1377637e3bea622132bb14
BLAKE2b-256 b3bec0c04d9306b9ce38404ede28c0db6f040e12cdb4595c8669a3cb04ea00a8

See more details on using hashes here.

File details

Details for the file py_timod-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: py_timod-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for py_timod-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96b4c87ac9809f9e615b25c2d42f24d23023f0029315fd21a05cfc19e7a17940
MD5 315c2fa4398b6933427bd871ad444301
BLAKE2b-256 106a03764c71861e287bd2408f663de7f81e9961c47765cb0cbbd0307cc9e235

See more details on using hashes here.

Supported by

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