Skip to main content

Python Independent Class Process. Uses serialization method with JSON

Project description

Dirio - Python Independent Class Process

PyPi Version Python Version Dirio GitHub last commit PyPi Downloads

The class in your main file becomes the client. Another working Class is created in parallel. When the client calls the method, the Class in the other file does the job. The class in the main file gets the reply to the method.

Features

  • Inherit Class independently from running script.
  • Uses serialization method with JSON
  • You do not wait in classes like Socket

Cons

  • Since it is JSON based, it supports; dict, list, tuple, int, str, float, bool, type (None). Does not support serialize of other types (like object etc)

Install

pip3 install dirio

or

pip install dirio

Usage

# Import module
from dirio import Dirio


# Inherit class
# args mut be tuple. Don't forget to put a comma -> args=(xx, )
try_cls = Dirio(target=TryClass, args=("arg1",), kwargs={"key1": "val1"})
# PARAMETERS:
#   target      : class : Target Class
#   args        : tuple : Arguments for Target Class
#   kwargs      : dict  : Keyword Arguments for Target Class
#   tempdir     : str   : Temporary directory path. If it is empty, system temp path is used.
#   keeperiod   : float : !!! Not activated. Do not use.
#   looperiod   : float : Independent Class renewal frequency. 
#                         Default: .05
#                         Smaller value, more CPU
#                         Bigger  value, delayed processing
#   worker      : bool  : You don't use. The class itself uses



# Standard, Call your method, 
# First time return value is None
try_cls.yourmethod("arg1", key="value")
#-> Returned: None

# In the next call, the return value is that of the previous one.
try_cls.yourmethod("arg1", key="value")
#-> Returned: "result_of_previous_call_returned"

# If you want to return the value of the method you are calling;
# Notice; dr_code=True used
call_code = try_cls.yourmethod("arg1", key="value", dr_code=True)
#-> call_code -> 12

# Give the result of call code 12
try_cls.yourmethod("arg1", key="value", dr_code=call_code)
#-> Returned: None

# After a short while. Call it directly from the dr_code
try_cls.dr_code(dr_code=call_code)
#-> Returned: "result_of_previous_call_returned"

# If None, the method operation is not yet run or finished.
# We can call again and again
try_cls.yourmethod("arg1", key="value", dr_code=call_code)
#-> Returned: "result_of_previous_call_returned"

# We can wait as long as we want the answer to arrive
# dr_wait=3.4 -> Wait 3.4 second
try_cls.yourmethod("arg1", key="value", dr_wait=3.4)
#-> Returned: "result_of_previous_call_returned"
# if the operation is not over
#-> Returned: None

# Wait until the reply comes
# dr_wait=-1 -> until the operation is over
try_cls.yourmethod("arg1", key="value", dr_wait=-1)
#-> Returned: "result_of_previous_call_returned"

# Terminate the Dirio Process. 
# Make sure to use this at the end of the script.
try_cls.dr_terminate()

# When the result of the code returns, run the function.
# Function must take a parameter named 'result'. The return value is put in this parameter.
try_cls.dr_bind(code=call_code, func=your_func, args=("arg1", ), kwargs={"key1": "val1"})
# -> Calling:  your_func(arg1, key1="val1", result="dr_result_value")

# If we check it in the cycle, it will get faster results.
# Sometimes need to check if there is event. Binds work this way.
try_cls.dr_binds_check()

# Is active, control
try_cls.dr_isactive()

NOTE : Sorry, my English is poor. I use translation.

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

dirio-0.1.4.tar.gz (10.1 kB view details)

Uploaded Source

Built Distributions

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

dirio-0.1.4-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

dirio-0.1.4-py2-none-any.whl (9.5 kB view details)

Uploaded Python 2

File details

Details for the file dirio-0.1.4.tar.gz.

File metadata

  • Download URL: dirio-0.1.4.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

File hashes

Hashes for dirio-0.1.4.tar.gz
Algorithm Hash digest
SHA256 0eeb6eb374e738702606c5f885c99f43947cde50852d0a54431d8078436cf257
MD5 238d010ae73f4b9a5d47860e6114df19
BLAKE2b-256 984e4725282e1c2e243cf69b56f9639560725be9cb5d931fe48e25b1231b2d87

See more details on using hashes here.

File details

Details for the file dirio-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: dirio-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

File hashes

Hashes for dirio-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c73e3caa381e605889e73cf4fbe8290935eb890d97669416db1ad03442a36690
MD5 f052f8a06941652ee7184afa4fbdd3f7
BLAKE2b-256 59be29b15aab6f3700d1327346ec10bbb3e9237d1b9cc47fa26ebea2aaba92bf

See more details on using hashes here.

File details

Details for the file dirio-0.1.4-py2-none-any.whl.

File metadata

  • Download URL: dirio-0.1.4-py2-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

File hashes

Hashes for dirio-0.1.4-py2-none-any.whl
Algorithm Hash digest
SHA256 3bae557299acc019d0fb292a667e44f094133cb78f97838d9cc547e0f2132f56
MD5 8146c79f01210bb3cdff80a6827e0b31
BLAKE2b-256 182ef1096dda6d84f2b254b10f8baea42f08a8932608aebf0b8148ca1343108b

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 Pingdom Monitoring Sentry Error logging StatusPage Status page